summaryrefslogtreecommitdiff
path: root/gtk/gtkplug.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-02-08 20:08:22 -0500
committerMatthias Clasen <mclasen@redhat.com>2010-02-09 13:41:57 -0500
commitbeddf67e562e1670d692cb9ba0a2546713cc80fc (patch)
tree3a57ad7f12cbcdfccbdbf3e228119b89c32fb95f /gtk/gtkplug.c
parent9fc642019eef6fc6bc2ad01fc2bfd4c07b720885 (diff)
downloadgtk+-beddf67e562e1670d692cb9ba0a2546713cc80fc.tar.gz
Fix a refcounting issues in GtkPlug
When the foreign window already has a GdkWindow, we forget to take an extra references, leading to crashes later on. Patch by Karl Tomlinson, bug 607061.
Diffstat (limited to 'gtk/gtkplug.c')
-rw-r--r--gtk/gtkplug.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 40623f0b2c..5289cb5dad 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -325,6 +325,7 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
socket_->plug_widget = widget;
plug->socket_window = GTK_WIDGET (socket_)->window;
+ g_object_ref (plug->socket_window);
if (GTK_WIDGET_REALIZED (widget))
{
@@ -410,10 +411,13 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
socket_->same_app = FALSE;
plug->same_app = FALSE;
- plug->socket_window = NULL;
-
+ if (plug->socket_window != NULL)
+ {
+ g_object_unref (plug->socket_window);
+ plug->socket_window = NULL;
+ }
gtk_plug_set_is_child (plug, FALSE);
-
+
g_signal_emit_by_name (socket_, "plug-removed", &result);
if (!result)
gtk_widget_destroy (GTK_WIDGET (socket_));
@@ -467,22 +471,25 @@ gtk_plug_construct_for_display (GtkPlug *plug,
gpointer user_data = NULL;
plug->socket_window = gdk_window_lookup_for_display (display, socket_id);
-
if (plug->socket_window)
- gdk_window_get_user_data (plug->socket_window, &user_data);
- else
- plug->socket_window = gdk_window_foreign_new_for_display (display, socket_id);
-
- if (user_data)
{
- if (GTK_IS_SOCKET (user_data))
- _gtk_plug_add_to_socket (plug, user_data);
- else
+ gdk_window_get_user_data (plug->socket_window, &user_data);
+
+ if (user_data)
{
- g_warning (G_STRLOC "Can't create GtkPlug as child of non-GtkSocket");
- plug->socket_window = NULL;
+ if (GTK_IS_SOCKET (user_data))
+ _gtk_plug_add_to_socket (plug, user_data);
+ else
+ {
+ g_warning (G_STRLOC "Can't create GtkPlug as child of non-GtkSocket");
+ plug->socket_window = NULL;
+ }
}
+ else
+ g_object_ref (plug->socket_window);
}
+ else
+ plug->socket_window = gdk_window_foreign_new_for_display (display, socket_id);
if (plug->socket_window) {
g_signal_emit (plug, plug_signals[EMBEDDED], 0);