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!)

This commit is contained in:
blizzard%redhat.com 2002-01-04 05:07:44 +00:00
parent 3a76e03209
commit 82de04b607
2 changed files with 20 additions and 13 deletions

View File

@ -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 */

View File

@ -322,7 +322,7 @@ protected:
gint mDragMotionX;
gint mDragMotionY;
guint mDragMotionTime;
nsCOMPtr<nsITimer> mDragMotionTimer;
guint mDragMotionTimerID;
nsCOMPtr<nsITimer> 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);