Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE!] [Gtk] Free toggleref on object destroy??? #203

Closed
wants to merge 1 commit into from

Conversation

Therzok
Copy link
Contributor

@Therzok Therzok commented Jun 14, 2017

Up for discussion. Should we do this on destroy? Should we also do it on dispose and also free the toggleref there?

@Therzok Therzok force-pushed the signal-free-on-destroy branch 2 times, most recently from 4e3bc71 to 1cef156 Compare June 14, 2017 11:59
@alanmcgovern
Copy link
Member

alanmcgovern commented Jun 16, 2017

It's expected that all references held on the widget will also be released; you should connect to the “destroy” signal if you hold a reference to widget and you wish to remove it when this function is called. It is not necessary to do so if you are implementing a GtkContainer, as you'll be able to use the GtkContainerClass.remove() virtual function for that. It's important to notice that gtk_widget_destroy() will only cause the widget to be finalized if no additional references, acquired using g_object_ref(), are held on it. In case additional references are in place, the widget will be in an "inert" state after calling this function; widget will still point to valid memory, allowing you to release the references you hold, but you may not query the widget's own state. You should typically call this function on top level widgets, and rarely on child widgets.
If we destroy a widget we should free the toggleref and we should dispose the toggleref too. Basically I think we should make Destroy act like a normal .NET Dispose would work - we suppress finalization and free the handle+signals.

@alanmcgovern
Copy link
Member

All things considered - I do not think this change is a breaking change in semantics as the widget is essentially unusable once Destroy is invoked. All we're doing is changing our code to complete the cleanup a little bit earlier.

I would like to test this for a day or three locally to make sure it doesn't trigger new issues due to bad re-use of destroyed widgets.

@Therzok Therzok force-pushed the signal-free-on-destroy branch 3 times, most recently from e54764b to 6cc4409 Compare June 16, 2017 11:30
@Therzok Therzok changed the title [DO NOT MERGE!] [Gtk] Free signals on object destroy??? [DO NOT MERGE!] [Gtk] Free toggleref on object destroy??? Jun 16, 2017
@Therzok Therzok closed this Feb 25, 2023
@Therzok Therzok deleted the signal-free-on-destroy branch February 25, 2023 17:37
@alanmcgovern
Copy link
Member

🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants