gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

GtkD 3.4.0 Destroy Dialog Assertion Failure #169

Closed gnunn1 closed 7 years ago

gnunn1 commented 7 years ago

I use the following style of code in Terminix when showing dialogs where a scope(exit) is used tod estroy the dialog:

EditTriggersDialog dlg = new EditTriggersDialog(cast(Window) getToplevel(), gsProfile);
scope (exit) {
    dlg.destroy();
}
dlg.showAll();
if (dlg.run() == ResponseType.APPLY) {
    gsProfile.setStrv(SETTINGS_PROFILE_TRIGGERS_KEY, dlg.getTriggers());
}

This worked fine in 3.3.0 but in the new 3.4.0 version it seems to be generating an assertion failure in GObject:

GLib-GObject:ERROR:gobject.c:2899:toggle_refs_notify: assertion failed: (tstack.n_toggle_refs == 1)

It looks to be caused by the unref added in ObjectG.d from this commit, if I comment that out I do not get the assertion failure any longer:

https://github.com/gtkd-developers/GtkD/commit/c62220514133140bfde723fd6d17a46790232d09

That commit was to fix a memory leak I reported in #165.

gnunn1 commented 7 years ago

I tried changing the scope(exit) to a try...finally and it didn't make any difference.

MikeWey commented 7 years ago

I've changed unref, to properly removing the toggle reference. This should stop GTK from trying to call the toggle callback in the cases where that would no longer be possible.

I can no longer reproduce the issue with this change.

gnunn1 commented 7 years ago

Thanks @MikeWey that does indeed work fine. Any chance of getting a 3.4.1 release with this change included?

MikeWey commented 7 years ago

Done.

gnunn1 commented 7 years ago

Thanks!