From 99e6fc82e3fca442b117264f18640c8d080db4c7 Mon Sep 17 00:00:00 2001 From: "blizzard%redhat.com" Date: Mon, 29 Nov 1999 21:28:57 +0000 Subject: [PATCH] code to prevent creating a window that is a child of an nsIWidget that has already been destroyed --- widget/src/gtk/nsGtkEventHandler.cpp | 4 ++- widget/src/gtk/nsWidget.cpp | 21 --------------- widget/src/gtk/nsWidget.h | 1 - widget/src/gtk/nsWindow.cpp | 39 +++++++++++++++++++++++++--- widget/src/gtk/nsWindow.h | 1 + 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/widget/src/gtk/nsGtkEventHandler.cpp b/widget/src/gtk/nsGtkEventHandler.cpp index 750ddc7a2d6..1ca27f1f012 100644 --- a/widget/src/gtk/nsGtkEventHandler.cpp +++ b/widget/src/gtk/nsGtkEventHandler.cpp @@ -844,6 +844,8 @@ handle_gdk_event (GdkEvent *event, gpointer data) nsWindow *window = (nsWindow *)gtk_object_get_data (object, "nsWindow"); GtkWidget *current_grab = gtk_grab_get_current(); + + // if there's a grab in progress, make sure to send it right to that widget. if (window->GrabInProgress()) { goto handle_as_superwin; } @@ -881,7 +883,7 @@ handle_gdk_event (GdkEvent *event, gpointer data) handle_key_release_event (NULL, &event->key, window); break; default: - window->HandleEvent (event); + window->HandleGDKEvent (event); } return; } diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index 75857818564..26688673fb5 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -1258,27 +1258,6 @@ void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint // mLastPoint.y = event.point.y; } -void -nsWidget::HandleEvent(GdkEvent *event) -{ - switch (event->any.type) - { - case GDK_MOTION_NOTIFY: - OnMotionNotifySignal (&event->motion); - break; - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - OnButtonPressSignal (&event->button); - break; - case GDK_BUTTON_RELEASE: - OnButtonReleaseSignal (&event->button); - break; - default: - break; - } -} - PRBool nsWidget::ConvertStatus(nsEventStatus aStatus) { switch(aStatus) { diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index 6baef0a1b77..f9494872b72 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -163,7 +163,6 @@ public: // Utility functions - void HandleEvent(GdkEvent *event); PRBool ConvertStatus(nsEventStatus aStatus); PRBool DispatchMouseEvent(nsMouseEvent& aEvent); PRBool DispatchStandardEvent(PRUint32 aMsg); diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 128078952f4..2fdd3a8d156 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -26,6 +26,8 @@ #include #include +// XXX FTSO nsWebShell +#include #include // For XA_STRING @@ -198,7 +200,7 @@ NS_IMETHODIMP nsWindow::Destroy() if (PR_FALSE == mOnDestroyCalled) { nsWidget::OnDestroy(); } - + if (mMozArea) { /* destroy the moz area. the superwin will be destroyed by that mozarea */ gtk_widget_destroy(mMozArea); @@ -832,6 +834,27 @@ nsWindow::InstallFocusOutSignal(GtkWidget * aWidget) GTK_SIGNAL_FUNC(nsWindow::FocusOutSignal)); } +void +nsWindow::HandleGDKEvent(GdkEvent *event) +{ + switch (event->any.type) + { + case GDK_MOTION_NOTIFY: + OnMotionNotifySignal (&event->motion); + break; + case GDK_BUTTON_PRESS: + case GDK_2BUTTON_PRESS: + case GDK_3BUTTON_PRESS: + OnButtonPressSignal (&event->button); + break; + case GDK_BUTTON_RELEASE: + OnButtonReleaseSignal (&event->button); + break; + default: + break; + } +} + #endif /* USE_SUPERWIN */ void @@ -1171,10 +1194,21 @@ void * nsWindow::GetNativeData(PRUint32 aDataType) #ifdef USE_SUPERWIN if (aDataType == NS_NATIVE_WINDOW) { - if (mSuperWin) + if (mSuperWin) { + GdkWindowPrivate *private_window = (GdkWindowPrivate *)mSuperWin->bin_window; + if (private_window->destroyed == PR_TRUE) { + return NULL; + } return (void *)mSuperWin->bin_window; + } } else if (aDataType == NS_NATIVE_WIDGET) { + if (mSuperWin) { + GdkWindowPrivate *private_window = (GdkWindowPrivate *)mSuperWin->bin_window; + if (private_window->destroyed == PR_TRUE) { + return NULL; + } + } return (void *)mSuperWin; } #else @@ -1986,7 +2020,6 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) } gdk_superwin_resize(mSuperWin, aWidth, aHeight); } - // XXX chris if (mIsToplevel || mListenForResizes) { //g_print("sending resize event\n"); nsSizeEvent sevent; diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index ffd6ce3ce43..cf952b9f69c 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -97,6 +97,7 @@ public: virtual void OnFocusOutSignal(GdkEventFocus * aGdkFocusEvent); virtual void InstallFocusInSignal(GtkWidget * aWidget); virtual void InstallFocusOutSignal(GtkWidget * aWidget); + void HandleGDKEvent(GdkEvent *event); #endif /* USE_SUPERWIN */ gint ConvertBorderStyles(nsBorderStyle bs);