Don't reuse dialog instances #434

Closed
hsoft opened this Issue Jul 6, 2015 · 0 comments

Projects

None yet

1 participant

@hsoft
Owner
hsoft commented Jul 6, 2015

Under the Qt UI, all dialogs are pre-instantiated at startup and reused throughout the app run. This brings all kinds of little glitches, such as #433.

Dialogs should be instantiated on-the-fly, when they're invoked by the user, and then destroyed. This will get us rid of a whole class of little problems.

@hsoft hsoft added feature qt labels Jul 6, 2015
@hsoft hsoft added this to the v2.10 milestone Jul 6, 2015
@hsoft hsoft added a commit that referenced this issue Jul 6, 2015
@hsoft Make BudgetPanel's instantiation "on-the-fly"
I start my "on-the-fly" adventure with the simplest one. It's a rather
tricky move, especially on the test side. I had to start weakref-ing my
references in dialogs so that instances would be properly deleted after
closing a dialog.

ref #434
d49b7b1
@hsoft hsoft self-assigned this Jul 18, 2015
@hsoft hsoft added a commit that closed this issue Jul 18, 2015
@hsoft Make panel instantiation on-the-fly
Prior to this commit, all panels were instantiated at startup,
references held by `MainWindow`. In addition to being inelegant and
wasteful in terms of resources, this led to some glitches like #433.

This commit makes all panel instantiation happen on-the-fly. The
`BaseView` is responsible to provide the panel with the appropriate UI-
layer view instance through `get_panel_view()`.

Conceptually, this change is very simple, but it results in quite many
SLOC changes, especially in test code. Previously all tests involving
panels (many) referred to those panels through global instances held by
`MainWindow`. Because these references no longer exist, we have to get
those instances elsewhere (see `TestApp.get_current_panel()`). That
changes the tests a lot.

We also introduce weakrefs in this commit. Previously, we would merrily
create circular references because most of our UI-related classes were
instantiated once, at startup (and thus released once, at shutdown). No
memory leak.

With on-the-fly instantiation, this changes. Unfreed panels are memory
leaks. We can't rely on Python's GC because under Cocoa, we have to mix
Python's memory model with ObjC's: as long as the UI layer is not
manually released, everything stays in memory. This is why we had to
break circular references. In this commit, I've made sure that every
panel's `__del__()` was called when a panel was closed. There are still
many circular references left in the app, but not in panels.

This is a squash commit of the "dialog-instance" branch.

fixes #434
1ac3b64
@hsoft hsoft closed this in 1ac3b64 Jul 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment