summaryrefslogtreecommitdiff
path: root/gtk/gtkscrolledwindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtkscrolledwindow.c')
-rw-r--r--gtk/gtkscrolledwindow.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index d637ce25eb..2c5b841ae6 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -25,6 +25,7 @@
static void gtk_scrolled_window_class_init (GtkScrolledWindowClass *klass);
static void gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window);
static void gtk_scrolled_window_destroy (GtkObject *object);
+static void gtk_scrolled_window_finalize (GtkObject *object);
static void gtk_scrolled_window_map (GtkWidget *widget);
static void gtk_scrolled_window_unmap (GtkWidget *widget);
static void gtk_scrolled_window_draw (GtkWidget *widget,
@@ -87,6 +88,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
parent_class = gtk_type_class (gtk_container_get_type ());
object_class->destroy = gtk_scrolled_window_destroy;
+ object_class->finalize = gtk_scrolled_window_finalize;
widget_class->map = gtk_scrolled_window_map;
widget_class->unmap = gtk_scrolled_window_unmap;
@@ -141,7 +143,11 @@ gtk_scrolled_window_new (GtkAdjustment *hadjustment,
gtk_widget_show (scrolled_window->viewport);
gtk_widget_show (scrolled_window->hscrollbar);
gtk_widget_show (scrolled_window->vscrollbar);
-
+
+ gtk_widget_ref (scrolled_window->viewport);
+ gtk_widget_ref (scrolled_window->hscrollbar);
+ gtk_widget_ref (scrolled_window->vscrollbar);
+
return GTK_WIDGET (scrolled_window);
}
@@ -202,6 +208,17 @@ gtk_scrolled_window_destroy (GtkObject *object)
}
static void
+gtk_scrolled_window_finalize (GtkObject *object)
+{
+ GtkScrolledWindow *scrolled_window;
+
+ scrolled_window = GTK_SCROLLED_WINDOW (object);
+ gtk_widget_unref (scrolled_window->viewport);
+ gtk_widget_unref (scrolled_window->hscrollbar);
+ gtk_widget_unref (scrolled_window->vscrollbar);
+}
+
+static void
gtk_scrolled_window_map (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window;
@@ -421,7 +438,16 @@ gtk_scrolled_window_remove (GtkContainer *container,
g_return_if_fail (widget != NULL);
scrolled_window = GTK_SCROLLED_WINDOW (container);
- gtk_container_remove (GTK_CONTAINER (scrolled_window->viewport), widget);
+
+ if (scrolled_window->viewport == widget ||
+ scrolled_window->hscrollbar == widget ||
+ scrolled_window->vscrollbar == widget)
+ {
+ /* this happens during destroy */
+ gtk_widget_unparent (widget);
+ }
+ else
+ gtk_container_remove (GTK_CONTAINER (scrolled_window->viewport), widget);
}
static void