From 40ab77790d6323116b3c31b2ee85f41b2200ba9a Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Wed, 31 Aug 2005 22:56:37 +0000 Subject: [PATCH] Bug 269568 Prevent crash by starting drag session before firing drag enter event patch also seems to fix a couple of my other drag-and-drop issues r+sr=bryner git-svn-id: svn://10.0.0.236/trunk@179443 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/gtk/nsWindow.cpp | 17 ++++++++--------- mozilla/widget/src/gtk2/nsWindow.cpp | 19 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index 61ff2aa14c5..b05692d737d 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -82,6 +82,7 @@ #include "nsIDragService.h" #include "nsIDragSessionGTK.h" +#include "nsAutoPtr.h" #include "nsGtkIMEHelper.h" #include "nsKeyboardUtils.h" @@ -3513,15 +3514,8 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) #ifdef DEBUG_DND_EVENTS g_print("nsWindow::OnDragEnter\n"); #endif /* DEBUG_DND_EVENTS */ - - nsMouseEvent event(PR_TRUE, NS_DRAGDROP_ENTER, this, nsMouseEvent::eReal); - event.refPoint.x = aX; - event.refPoint.y = aY; - - AddRef(); - - DispatchMouseEvent(event); + nsRefPtr kungFuDeathGrip(this); nsCOMPtr dragService = do_GetService(kCDragServiceCID); @@ -3530,7 +3524,12 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) dragService->StartDragSession(); } - Release(); + nsMouseEvent event(PR_TRUE, NS_DRAGDROP_ENTER, this, nsMouseEvent::eReal); + + event.refPoint.x = aX; + event.refPoint.y = aY; + + DispatchMouseEvent(event); } void diff --git a/mozilla/widget/src/gtk2/nsWindow.cpp b/mozilla/widget/src/gtk2/nsWindow.cpp index 41596958ac9..9daadf0001b 100644 --- a/mozilla/widget/src/gtk2/nsWindow.cpp +++ b/mozilla/widget/src/gtk2/nsWindow.cpp @@ -93,6 +93,7 @@ static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility" #include "nsIImage.h" #include "nsIGdkPixbufImage.h" #include "nsIInterfaceRequestorUtils.h" +#include "nsAutoPtr.h" /* For PrepareNativeWidget */ static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); @@ -2201,15 +2202,7 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) LOG(("nsWindow::OnDragEnter(%p)\n", this)); - nsMouseEvent event(PR_TRUE, NS_DRAGDROP_ENTER, this, nsMouseEvent::eReal); - - event.refPoint.x = aX; - event.refPoint.y = aY; - - AddRef(); - - nsEventStatus status; - DispatchEvent(&event, status); + nsRefPtr kungFuDeathGrip(this); nsCOMPtr dragService = do_GetService(kCDragServiceCID); @@ -2218,7 +2211,13 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) dragService->StartDragSession(); } - Release(); + nsMouseEvent event(PR_TRUE, NS_DRAGDROP_ENTER, this, nsMouseEvent::eReal); + + event.refPoint.x = aX; + event.refPoint.y = aY; + + nsEventStatus status; + DispatchEvent(&event, status); } nsresult