GNOME Bugzilla – Bug 689879
embed: be more careful when adding and removing the filter function
Last modified: 2012-12-12 21:23:21 UTC
See attached patch.
Created attachment 231019 [details] [review] embed: be more careful when adding and removing the filter function The intention of the current code seems to be adding a global event filter instead of one per realized embed; the filter is unconditionally removed in unrealize() though. This is a problem if an embed is unrealized and another one is realized later (for instance because a window is destroyed and another window is recreated later). Fix the bug by tracking the number of realized embeds with a counter, and removing the event filter only when the counter reaches zero.
Review of attachment 231019 [details] [review]: looks okay - just some minor style issues. ::: clutter-gtk/gtk-clutter-embed.c @@ +344,3 @@ clutter_x11_set_stage_foreign (CLUTTER_STAGE (priv->stage), GDK_WINDOW_XID (window)); + if (!num_filter) please, use num_filter == 0 @@ +356,3 @@ clutter_win32_set_stage_foreign (CLUTTER_STAGE (priv->stage), GDK_WINDOW_HWND (window)); + if (!num_filter) same as above. @@ +379,3 @@ + { + gdk_window_remove_filter (NULL, gtk_clutter_filter_func, widget); + num_filter = 0; this should really be: if (num_filter > 0) { remove_filter(); num_filter -= 1; }
Created attachment 231316 [details] [review] embed: be more careful when adding and removing the filter function -- - update for review comments - I think the double check (first > 0 and then == 0) in unrealize() is needed, as it seems not all code paths in realize() might increase the counter/add a filter.
Review of attachment 231316 [details] [review]: looks good
Attachment 231316 [details] pushed as e0bfbaf - embed: be more careful when adding and removing the filter function Pushed, thanks for the review!