Bug 629253 - Firefox hangs when dragging two emails from Thunderbird over it. r=khuey
authorBrian R. Bondy <netzen@gmail.com>
Thu, 08 Sep 2011 21:04:12 -0400
changeset 76801 e48615c337829fc96c779f4ee9c37efeeec3143b
parent 76800 09eb988935285cb445e3faf4f80da3ff431df59c
child 76802 edb32fa29bca558a5afc8c9afb363fbc98873fe0
push id21141
push usereakhgari@mozilla.com
push dateFri, 09 Sep 2011 14:06:30 +0000
treeherdermozilla-central@694520af9b18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs629253
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 629253 - Firefox hangs when dragging two emails from Thunderbird over it. r=khuey
widget/src/windows/nsDragService.cpp
--- a/widget/src/windows/nsDragService.cpp
+++ b/widget/src/windows/nsDragService.cpp
@@ -209,17 +209,17 @@ nsDragService::InvokeDragSession(nsIDOMN
   if (!numItemsToDrag)
     return NS_ERROR_FAILURE;
 
   // The clipboard class contains some static utility methods that we
   // can use to create an IDataObject from the transferable
 
   // if we're dragging more than one item, we need to create a
   // "collection" object to fake out the OS. This collection contains
-  // one |IDataObject| for each transerable. If there is just the one
+  // one |IDataObject| for each transferable. If there is just the one
   // (most cases), only pass around the native |IDataObject|.
   nsRefPtr<IDataObject> itemToDrag;
   if (numItemsToDrag > 1) {
     nsDataObjCollection * dataObjCollection = new nsDataObjCollection();
     if (!dataObjCollection)
       return NS_ERROR_OUT_OF_MEMORY;
     itemToDrag = dataObjCollection;
     for (PRUint32 i=0; i<numItemsToDrag; ++i) {
@@ -382,18 +382,27 @@ nsDragService::GetNumDropItems(PRUint32 
 {
   if (!mDataObject) {
     *aNumItems = 0;
     return NS_OK;
   }
 
   if (IsCollectionObject(mDataObject)) {
     nsDataObjCollection * dataObjCol = GetDataObjCollection(mDataObject);
-    if (dataObjCol)
+    if (dataObjCol) {
       *aNumItems = dataObjCol->GetNumDataObjects();
+    }
+    else {
+      // If the count cannot be determined just return 0.
+      // This can happen if we have collection data of type 
+      // MULTI_MIME ("Mozilla/IDataObjectCollectionFormat") on the clipboard
+      // from another process but we can't obtain an IID_IDataObjCollection
+      // from this process.
+      *aNumItems = 0;
+    }
   }
   else {
     // Next check if we have a file drop. Return the number of files in
     // the file drop as the number of items we have, pretending like we
     // actually have > 1 drag item.
     FORMATETC fe2;
     SET_FORMATETC(fe2, CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
     if (mDataObject->QueryGetData(&fe2) == S_OK) {