summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-04-10 23:16:30 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-04-10 23:16:30 +0000
commit3b95bc271da8416b7a8754e8d95bf0cfc498a4d0 (patch)
tree8c3ce5f9521aefddcb7e192c4692091456011e8f /gdk
parent1b0bbc87730f47bb3199f0b9d4952c4a6a3f91a4 (diff)
downloadgtk+-3b95bc271da8416b7a8754e8d95bf0cfc498a4d0.tar.gz
Change the XSettingsWatchFunc to return a Bool to indicate success. Update
2007-04-10 Matthias Clasen <mclasen@redhat.com> * gdk/x11/xsettings-client.[hc]: Change the XSettingsWatchFunc to return a Bool to indicate success. Update callers and implementors. Based on a patch by Owen Taylor. * gdk/x11/gdkevents-x11.c (gdk_xsettings_watch_cb): Don't leak a reference to gdkwin. svn path=/trunk/; revision=17592
Diffstat (limited to 'gdk')
-rw-r--r--gdk/x11/gdkevents-x11.c37
-rw-r--r--gdk/x11/xsettings-client.c16
-rw-r--r--gdk/x11/xsettings-client.h2
3 files changed, 44 insertions, 11 deletions
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index 7cdfc88450..6df08bb3df 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -111,7 +111,7 @@ static GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
static GSource *gdk_display_source_new (GdkDisplay *display);
static gboolean gdk_check_xpending (GdkDisplay *display);
-static void gdk_xsettings_watch_cb (Window window,
+static Bool gdk_xsettings_watch_cb (Window window,
Bool is_start,
long mask,
void *cb_data);
@@ -2993,7 +2993,7 @@ gdk_xsettings_client_event_filter (GdkXEvent *xevent,
return GDK_FILTER_CONTINUE;
}
-static void
+static Bool
gdk_xsettings_watch_cb (Window window,
Bool is_start,
long mask,
@@ -3006,16 +3006,39 @@ gdk_xsettings_watch_cb (Window window,
if (is_start)
{
- if (!gdkwin)
- gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
-
+ if (gdkwin)
+ g_object_ref (gdkwin);
+ else
+ {
+ gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
+
+ /* gdk_window_foreign_new_for_display() can fail and return NULL if the
+ * window has already been destroyed.
+ */
+ if (!gdkwin)
+ return False;
+ }
+
gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
}
else
{
- if (gdkwin)
- gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
+ if (!gdkwin)
+ {
+ /* gdkwin should not be NULL here, since if starting the watch succeeded
+ * we have a reference on the window. It might mean that the caller didn't
+ * remove the watch when it got a DestroyNotify event. Or maybe the
+ * caller ignored the return value when starting the watch failed.
+ */
+ g_warning ("gdk_xsettings_watch_cb(): Couldn't find window to unwatch");
+ return False;
+ }
+
+ gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
+ g_object_unref (gdkwin);
}
+
+ return True;
}
#define __GDK_EVENTS_X11_C__
diff --git a/gdk/x11/xsettings-client.c b/gdk/x11/xsettings-client.c
index d17e4213a6..93e0d7e1b2 100644
--- a/gdk/x11/xsettings-client.c
+++ b/gdk/x11/xsettings-client.c
@@ -441,9 +441,19 @@ check_manager_window (XSettingsClient *client)
XFlush (client->display);
if (client->manager_window && client->watch)
- client->watch (client->manager_window, True,
- PropertyChangeMask | StructureNotifyMask,
- client->cb_data);
+ {
+ if (!client->watch (client->manager_window, True,
+ PropertyChangeMask | StructureNotifyMask,
+ client->cb_data))
+ {
+ /* Inability to watch the window probably means that it was destroyed
+ * after we ungrabbed
+ */
+ client->manager_window = None;
+ return;
+ }
+ }
+
read_settings (client);
}
diff --git a/gdk/x11/xsettings-client.h b/gdk/x11/xsettings-client.h
index ba34130107..710ed12482 100644
--- a/gdk/x11/xsettings-client.h
+++ b/gdk/x11/xsettings-client.h
@@ -43,7 +43,7 @@ typedef void (*XSettingsNotifyFunc) (const char *name,
XSettingsAction action,
XSettingsSetting *setting,
void *cb_data);
-typedef void (*XSettingsWatchFunc) (Window window,
+typedef Bool (*XSettingsWatchFunc) (Window window,
Bool is_start,
long mask,
void *cb_data);