From de18adfc8dd95d2321cf5c065072dfa4cf142389 Mon Sep 17 00:00:00 2001 From: "joshmoz@gmail.com" Date: Tue, 17 Jul 2007 16:02:40 -0700 Subject: [PATCH] followup for 358093, take care of some lifetime and null checking issues for the global drag transferables variable. b=388382 r=shebs --- widget/src/cocoa/nsChildView.mm | 11 ++++++++--- widget/src/cocoa/nsDragService.mm | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 102e48a3c5d..1ab1783c0f7 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -85,6 +85,8 @@ extern "C" { CG_EXTERN void CGContextResetClip(CGContextRef); } +extern nsISupportsArray *gDraggedTransferables; + PRBool nsTSMManager::sIsIMEEnabled = PR_TRUE; PRBool nsTSMManager::sIsRomanKeyboardsOnly = PR_FALSE; NSView* nsTSMManager::sComposingView = nsnull; @@ -4203,6 +4205,8 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode) // NSDraggingSource - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { + gDraggedTransferables = nsnull; + if (!mDragService) { CallGetService(kDragServiceContractID, &mDragService); NS_ASSERTION(mDragService, "Couldn't get a drag service - big problem!"); @@ -4248,16 +4252,17 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode) return nil; } - extern nsISupportsArray *draggedTransferables; + if (!gDraggedTransferables) + return nil; PRUint32 transferableCount; - rv = draggedTransferables->Count(&transferableCount); + rv = gDraggedTransferables->Count(&transferableCount); if (NS_FAILED(rv)) return nil; for (PRUint32 i = 0; i < transferableCount; i++) { nsCOMPtr genericItem; - draggedTransferables->GetElementAt(i, getter_AddRefs(genericItem)); + gDraggedTransferables->GetElementAt(i, getter_AddRefs(genericItem)); nsCOMPtr item(do_QueryInterface(genericItem)); if (!item) { NS_ERROR("no transferable"); diff --git a/widget/src/cocoa/nsDragService.mm b/widget/src/cocoa/nsDragService.mm index 34f8dd4d1a0..a71cdbe6260 100644 --- a/widget/src/cocoa/nsDragService.mm +++ b/widget/src/cocoa/nsDragService.mm @@ -71,7 +71,7 @@ extern NSEvent* globalDragEvent; // This global makes the transferable array available to Cocoa's promised // file destination callback. -nsISupportsArray *draggedTransferables; +nsISupportsArray *gDraggedTransferables = nsnull; NSString* const kWildcardPboardType = @"MozillaWildcard"; @@ -267,7 +267,7 @@ nsDragService::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aTransf NSPoint localPoint = [globalDragView convertPoint:point fromView:nil]; // Save the transferables away in case a promised file callback is invoked. - draggedTransferables = aTransferableArray; + gDraggedTransferables = aTransferableArray; nsBaseDragService::StartDragSession();