From 918d3b4c4e1a35f4e1edbbebb6478eb3b6bebeef Mon Sep 17 00:00:00 2001 From: "blizzard%redhat.com" Date: Sat, 4 Mar 2000 05:04:33 +0000 Subject: [PATCH] fix memory leak documented in bug #29945. actually use refcnting the way it is supposed to be. r=pavlov --- widget/src/gtk/nsWindow.cpp | 2 +- widget/src/gtksuperwin/gdksuperwin.c | 16 +++++++++++++--- widget/src/gtksuperwin/gdksuperwin.h | 1 - widget/src/gtksuperwin/gtkmozarea.c | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 4efa03b7a8e2..e374ff07ff55 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -231,7 +231,7 @@ nsWindow::DestroyNative(void) mSuperWin = nsnull; } else if(mSuperWin) { - gdk_superwin_destroy(mSuperWin); + gtk_object_unref(GTK_OBJECT(mSuperWin)); mSuperWin = NULL; } } diff --git a/widget/src/gtksuperwin/gdksuperwin.c b/widget/src/gtksuperwin/gdksuperwin.c index 2446f9c2069c..74bc79b45f8a 100644 --- a/widget/src/gtksuperwin/gdksuperwin.c +++ b/widget/src/gtksuperwin/gdksuperwin.c @@ -24,6 +24,7 @@ static void gdk_superwin_expose_area (GdkSuperWin *superwin, gint y, gint width, gint height); +static void gdk_superwin_destroy(GtkObject *object); static int gdk_superwin_clear_rect_queue(GdkSuperWin *superwin, XEvent *xevent); static void gdk_superwin_clear_translate_queue(GdkSuperWin *superwin, unsigned long serial); @@ -77,9 +78,8 @@ gdk_superwin_class_init(GdkSuperWinClass *klass) GtkObjectClass *object_class; object_class = GTK_OBJECT_CLASS(klass); + object_class->destroy = gdk_superwin_destroy; - /* XXX do we need a finalize in here to destroy the - window? */ } static void @@ -170,8 +170,18 @@ gdk_superwin_new (GdkWindow *parent_window, /* XXX this should really be part of the object... */ /* XXX and it should chain up to the object's destructor */ -void gdk_superwin_destroy(GdkSuperWin *superwin) +void gdk_superwin_destroy(GtkObject *object) { + + GdkSuperWin *superwin = NULL; + + g_return_if_fail(object != NULL); + g_return_if_fail(GTK_IS_OBJECT(object)); + g_return_if_fail(GTK_OBJECT_CONSTRUCTED(object)); + g_return_if_fail(GDK_IS_SUPERWIN(object)); + + superwin = GDK_SUPERWIN(object); + gdk_window_remove_filter(superwin->shell_window, gdk_superwin_shell_filter, superwin); diff --git a/widget/src/gtksuperwin/gdksuperwin.h b/widget/src/gtksuperwin/gdksuperwin.h index 4b4e9e3a771a..35ec68bd589f 100644 --- a/widget/src/gtksuperwin/gdksuperwin.h +++ b/widget/src/gtksuperwin/gdksuperwin.h @@ -88,7 +88,6 @@ void gdk_superwin_scroll (GdkSuperWin *superwin, void gdk_superwin_resize (GdkSuperWin *superwin, gint width, gint height); -void gdk_superwin_destroy(GdkSuperWin *superwin); #ifdef __cplusplus } diff --git a/widget/src/gtksuperwin/gtkmozarea.c b/widget/src/gtksuperwin/gtkmozarea.c index c8adec5c3dfc..cc68ba399414 100644 --- a/widget/src/gtksuperwin/gtkmozarea.c +++ b/widget/src/gtksuperwin/gtkmozarea.c @@ -107,7 +107,7 @@ gtk_mozarea_unrealize(GtkWidget *widget) mozarea = GTK_MOZAREA(widget); if (mozarea->superwin) { - gdk_superwin_destroy(mozarea->superwin); + gtk_object_unref(GTK_OBJECT(mozarea->superwin)); mozarea->superwin = NULL; } GTK_WIDGET_CLASS(parent_class)->unrealize(widget);