From d43d2327054d3369c0a7fb8c3d93b78ce71e9e31 Mon Sep 17 00:00:00 2001 From: "blizzard%redhat.com" Date: Fri, 4 Jan 2002 05:07:44 +0000 Subject: [PATCH] Bug #115764. sporadic Trunk crashes in [@ nsWindow::OnDragMotionSignal] w/drag'n'drop. Use cool and smooth native gtk timers instead of cranky fake-o XP timers that don't have a deterministic order in the mainloop. r=bryner, sr=shaver (2!) git-svn-id: svn://10.0.0.236/trunk@111345 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/gtk/nsWindow.cpp | 27 +++++++++++++++++---------- mozilla/widget/src/gtk/nsWindow.h | 6 +++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index a11b3a3fd8c..9bf649b1549 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -208,6 +208,7 @@ nsWindow::nsWindow() mDragMotionX = 0; mDragMotionY = 0; mDragMotionTime = 0; + mDragMotionTimerID = 0; // for commit character mIMECompositionUniString = nsnull; @@ -3655,20 +3656,25 @@ nsWindow::ResetDragMotionTimer(GtkWidget *aWidget, mDragMotionY = aY; mDragMotionTime = aTime; - // clear the timer - if (!aWidget) { - // destroying the timer will cancel it - mDragMotionTimer = 0; + // always clear the timer + if (mDragMotionTimerID) { + gtk_timeout_remove(mDragMotionTimerID); + mDragMotionTimerID = 0; #ifdef DEBUG_DND_EVENTS - g_print("*** canceled motion timer\n"); + g_print("*** canceled motion timer\n"); #endif + } + + // if no widget was passed in, just return instead of setting a new + // timer + if (!aWidget) { return; } // otherwise we create a new timer - mDragMotionTimer = do_CreateInstance("@mozilla.org/timer;1"); - NS_ASSERTION(mDragMotionTimer, "Failed to create drag motion timer!"); - mDragMotionTimer->Init(DragMotionTimerCallback, this, 100); + mDragMotionTimerID = gtk_timeout_add(100, + (GtkFunction)DragMotionTimerCallback, + this); } void @@ -3704,11 +3710,12 @@ nsWindow::FireDragLeaveTimer(void) } /* static */ -void -nsWindow::DragMotionTimerCallback(nsITimer *aTimer, void *aClosure) +guint +nsWindow::DragMotionTimerCallback(gpointer aClosure) { nsWindow *window = NS_STATIC_CAST(nsWindow *, aClosure); window->FireDragMotionTimer(); + return FALSE; } /* static */ diff --git a/mozilla/widget/src/gtk/nsWindow.h b/mozilla/widget/src/gtk/nsWindow.h index 831078edaf6..100a28d2a6e 100644 --- a/mozilla/widget/src/gtk/nsWindow.h +++ b/mozilla/widget/src/gtk/nsWindow.h @@ -322,7 +322,7 @@ protected: gint mDragMotionX; gint mDragMotionY; guint mDragMotionTime; - nsCOMPtr mDragMotionTimer; + guint mDragMotionTimerID; nsCOMPtr mDragLeaveTimer; void ResetDragMotionTimer (GtkWidget *aWidget, @@ -332,8 +332,8 @@ protected: guint aTime); void FireDragMotionTimer (void); void FireDragLeaveTimer (void); - static void DragMotionTimerCallback (nsITimer *aTimer, void *aClosure); - static void DragLeaveTimerCallback (nsITimer *aTimer, void *aClosure); + static guint DragMotionTimerCallback (gpointer aClosure); + static void DragLeaveTimerCallback (nsITimer *aTimer, void *aClosure); #ifdef NS_DEBUG void DumpWindowTree(void);