Discussion:
dispose, finalize and close_impl methods not been called for glade_project
Marco Diego Aurélio Mesquita
2011-01-11 04:22:37 UTC
Permalink
Hi devs!

I'm working on some improvements for the preview feature[1] but I got
stuck. Glade must kill current running previews when a project is
closed, but, I don't know why, the finalize, dispose, and close_impl
methods are not been called. What is happening? What should I do?

The attached is part of my ongoing work on this issue. It's full of
debug printf's but shows that the finalize, dispose, and close_impl
methods are not been called.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=637835
Tristan Van Berkom
2011-01-11 10:25:05 UTC
Permalink
Post by Marco Diego Aurélio Mesquita
Hi devs!
I'm working on some improvements for the preview feature[1] but I got
stuck. Glade must kill current running previews when a project is
closed, but, I don't know why, the finalize, dispose, and close_impl
methods are not been called. What is happening? What should I do?
The attached is part of my ongoing work on this issue. It's full of
debug printf's but shows that the finalize, dispose, and close_impl
methods are not been called.
I looked at the patch briefly, currently it still includes
unneeded functions like glade_preview_kill_preview().

- glade_preview_kill_preview() should be an implied exercise
by way of finalizing a GladePreview.
- The hash table bookkeeping the running previews should
hold the reference to the previews (i.e. the GDestroyNotify
for the hash table of previews should be g_object_unref).
- glade_preview_add_watch() should go away and the watch should
be added internally by the preview object, and destroyed
properly when the preview is unreffed.
- If the preview is notified that the child preview process
died, it should emit a "die" signal so that the GladeProject
which owns the preview can use that to remove it from the
hash table, resulting in it's dispose/finalize.

Please deal with these basic API/functionality issues first,
if the ref counts dont balance after that I'll help you take
a look at it and make sure that it finalizes properly.

Hint:
From GladeProject creating a preview should be:

/* comes with initial ref */
preview = glade_preview_launch (...);

/* hash table takes a ref */
g_hash_table_insert (project->priv->preview_hash, preview...);

/* pass ownership of the preview to the hash table */
g_object_unref (preview);

/* Watch previews that die */
g_signal_connect (preview, "die",
G_CALLBACK (remove_preview_from_hash_cb),
project);


... furthermore, the GDestroyNotify for the preview hash should
be a function that first disconnects the "die" signal callback
and *then* unrefs the preview.

Cheers,
-Tristan
Post by Marco Diego Aurélio Mesquita
[1] https://bugzilla.gnome.org/show_bug.cgi?id=637835
_______________________________________________
http://lists.ximian.com/mailman/listinfo/glade-devel
_______________________________________________
Glade-devel maillist - Glade-***@lists.ximian.com
http://lists.ximi
Tristan Van Berkom
2011-01-11 10:27:53 UTC
Permalink
Post by Tristan Van Berkom
Post by Marco Diego Aurélio Mesquita
Hi devs!
I'm working on some improvements for the preview feature[1] but I got
stuck. Glade must kill current running previews when a project is
closed, but, I don't know why, the finalize, dispose, and close_impl
methods are not been called. What is happening? What should I do?
The attached is part of my ongoing work on this issue. It's full of
debug printf's but shows that the finalize, dispose, and close_impl
methods are not been called.
I looked at the patch briefly, currently it still includes
unneeded functions like glade_preview_kill_preview().
- glade_preview_kill_preview() should be an implied exercise
by way of finalizing a GladePreview.
- The hash table bookkeeping the running previews should
hold the reference to the previews (i.e. the GDestroyNotify
for the hash table of previews should be g_object_unref).
- glade_preview_add_watch() should go away and the watch should
be added internally by the preview object, and destroyed
properly when the preview is unreffed.
- If the preview is notified that the child preview process
died, it should emit a "die" signal so that the GladeProject
which owns the preview can use that to remove it from the
hash table, resulting in it's dispose/finalize.
Please deal with these basic API/functionality issues first,
if the ref counts dont balance after that I'll help you take
a look at it and make sure that it finalizes properly.
/* comes with initial ref */
preview = glade_preview_launch (...);
/* hash table takes a ref */
g_hash_table_insert (project->priv->preview_hash, preview...);
/* pass ownership of the preview to the hash table */
g_object_unref (preview);
Correction, you wouldn't need to unref the preview explicitly
here because above you give the initial ref to the hash table.

Cheers,
-Tristan
Post by Tristan Van Berkom
/* Watch previews that die */
g_signal_connect (preview, "die",
G_CALLBACK (remove_preview_from_hash_cb),
project);
... furthermore, the GDestroyNotify for the preview hash should
be a function that first disconnects the "die" signal callback
and *then* unrefs the preview.
Cheers,
-Tristan
Post by Marco Diego Aurélio Mesquita
[1] https://bugzilla.gnome.org/show_bug.cgi?id=637835
_______________________________________________
http://lists.ximian.com/mailman/listinfo/glade-devel
_______________________________________________
http://lists.ximian.com/mailman/listinfo/glade-devel
_______________________________________________
Glade-devel maillist - Glade-***@lists.ximian.com
http://lists.ximian.com/mailma

Loading...