GNOME Bugzilla – Bug 638580
'application' window's property released too late
Last modified: 2011-01-03 18:13:10 UTC
Currently GtkWindow auto-releases 'application' in window's finalize method; this causes problems for higher-language bindings, which tend to store its own reference to toplevel window objects. This forces higher-level languages to have some code like this (Lua pseudocode): function window_instance:on_destroy() window_instance.application = nil end i.e. creating 'destroy' signal handler which unsets window's 'application' property (and thus actually allows application to terminate GApplication.run() loop).
Created attachment 177413 [details] [review] Move gtk_window_release_application() call from finalize to gtk_window_destroy(). Releases GtkWindow's 'application' property in window_destroy instead of finalize. I'm not sure whether the call to gtk_window_release_application() should also remain in finalize method, but I can't come up with case how the window could be destroyed without gtk_window_destroy() being called.
I think I would prefer for the release call in finalize() to remain. If not, then setting the 'application' property on an already-destroyed window will leak the application when the window is finally finalized. Otherwise it seems okay.