After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689879 - embed: be more careful when adding and removing the filter function
embed: be more careful when adding and removing the filter function
Status: RESOLVED FIXED
Product: clutter-gtk
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: clutter-gtk maintainer(s)
clutter-gtk maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-12-08 03:24 UTC by Cosimo Cecchi
Modified: 2012-12-12 21:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
embed: be more careful when adding and removing the filter function (2.98 KB, patch)
2012-12-08 03:24 UTC, Cosimo Cecchi
reviewed Details | Review
embed: be more careful when adding and removing the filter function (3.00 KB, patch)
2012-12-12 01:01 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2012-12-08 03:24:10 UTC
See attached patch.
Comment 1 Cosimo Cecchi 2012-12-08 03:24:11 UTC
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.
Comment 2 Emmanuele Bassi (:ebassi) 2012-12-11 14:28:19 UTC
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;
    }
Comment 3 Cosimo Cecchi 2012-12-12 01:01:21 UTC
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.
Comment 4 Emmanuele Bassi (:ebassi) 2012-12-12 21:04:48 UTC
Review of attachment 231316 [details] [review]:

looks good
Comment 5 Cosimo Cecchi 2012-12-12 21:23:19 UTC
Attachment 231316 [details] pushed as e0bfbaf - embed: be more careful when adding and removing the filter function

Pushed, thanks for the review!