From 6f188e4a266d132f6a4e287bae6060eca9f86b70 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Tue, 19 Oct 2010 17:21:10 -0400 Subject: [PATCH] Bug 604860: Stop doing silly leaky stuff with nsDataObjs. r=jimm a=joe --- widget/src/windows/nsDataObj.cpp | 7 ---- widget/src/windows/nsDataObjCollection.cpp | 42 ---------------------- widget/src/windows/nsDataObjCollection.h | 8 ----- widget/src/windows/nsDragService.cpp | 30 ++++------------ 4 files changed, 7 insertions(+), 80 deletions(-) diff --git a/widget/src/windows/nsDataObj.cpp b/widget/src/windows/nsDataObj.cpp index 11f2cc637ea..9261cbe71d5 100644 --- a/widget/src/windows/nsDataObj.cpp +++ b/widget/src/windows/nsDataObj.cpp @@ -756,15 +756,11 @@ STDMETHODIMP nsDataObj::EndOperation(HRESULT hResult, DWORD dwEffects) { mIsInOperation = FALSE; - Release(); return S_OK; } STDMETHODIMP nsDataObj::GetAsyncMode(BOOL *pfIsOpAsync) { - if (!pfIsOpAsync) - return E_FAIL; - *pfIsOpAsync = mIsAsyncMode; return S_OK; @@ -772,9 +768,6 @@ STDMETHODIMP nsDataObj::GetAsyncMode(BOOL *pfIsOpAsync) STDMETHODIMP nsDataObj::InOperation(BOOL *pfInAsyncOp) { - if (!pfInAsyncOp) - return E_FAIL; - *pfInAsyncOp = mIsInOperation; return S_OK; diff --git a/widget/src/windows/nsDataObjCollection.cpp b/widget/src/windows/nsDataObjCollection.cpp index c9819926391..3b11cd1319a 100644 --- a/widget/src/windows/nsDataObjCollection.cpp +++ b/widget/src/windows/nsDataObjCollection.cpp @@ -257,48 +257,6 @@ void nsDataObjCollection::AddDataObject(IDataObject * aDataObj) mDataObjects.AppendElement(dataObj); } -// IAsyncOperation methods -STDMETHODIMP nsDataObjCollection::EndOperation(HRESULT hResult, - IBindCtx *pbcReserved, - DWORD dwEffects) -{ - mIsInOperation = FALSE; - Release(); - return S_OK; -} - -STDMETHODIMP nsDataObjCollection::GetAsyncMode(BOOL *pfIsOpAsync) -{ - if (!pfIsOpAsync) - return E_FAIL; - - *pfIsOpAsync = mIsAsyncMode; - - return S_OK; -} - -STDMETHODIMP nsDataObjCollection::InOperation(BOOL *pfInAsyncOp) -{ - if (!pfInAsyncOp) - return E_FAIL; - - *pfInAsyncOp = mIsInOperation; - - return S_OK; -} - -STDMETHODIMP nsDataObjCollection::SetAsyncMode(BOOL fDoOpAsync) -{ - mIsAsyncMode = fDoOpAsync; - return S_OK; -} - -STDMETHODIMP nsDataObjCollection::StartOperation(IBindCtx *pbcReserved) -{ - mIsInOperation = TRUE; - return S_OK; -} - // Methods for getting data HRESULT nsDataObjCollection::GetFile(LPFORMATETC pFE, LPSTGMEDIUM pSTM) { diff --git a/widget/src/windows/nsDataObjCollection.h b/widget/src/windows/nsDataObjCollection.h index db0aa3a6d96..c85e3afac3f 100644 --- a/widget/src/windows/nsDataObjCollection.h +++ b/widget/src/windows/nsDataObjCollection.h @@ -154,14 +154,6 @@ class nsDataObjCollection : public nsIDataObjCollection, public nsDataObj // Return the adapter //CfDragDrop& GetDragDrop() const; - - // IAsyncOperation methods - STDMETHOD(EndOperation)(HRESULT hResult, IBindCtx *pbcReserved, - DWORD dwEffects); - STDMETHOD(GetAsyncMode)(BOOL *pfIsOpAsync); - STDMETHOD(InOperation)(BOOL *pfInAsyncOp); - STDMETHOD(SetAsyncMode)(BOOL fDoOpAsync); - STDMETHOD(StartOperation)(IBindCtx *pbcReserved); protected: BOOL FormatsMatch(const FORMATETC& source, const FORMATETC& target) const; diff --git a/widget/src/windows/nsDragService.cpp b/widget/src/windows/nsDragService.cpp index 071082fcb55..39bc27434b0 100644 --- a/widget/src/windows/nsDragService.cpp +++ b/widget/src/windows/nsDragService.cpp @@ -303,34 +303,18 @@ nsDragService::StartInvokingDragSession(IDataObject * aDataObj, // Start dragging StartDragSession(); - // check shell32.dll version and do async drag if it is >= 5.0 - PRUint64 lShellVersion = GetShellVersion(); - IAsyncOperation *pAsyncOp = NULL; - PRBool isAsyncAvailable = LL_UCMP(lShellVersion, >=, LL_INIT(5, 0)); - if (isAsyncAvailable) - { - // do async drag - if (SUCCEEDED(aDataObj->QueryInterface(IID_IAsyncOperation, - (void**)&pAsyncOp))) - pAsyncOp->SetAsyncMode(VARIANT_TRUE); + nsRefPtr pAsyncOp; + // Offer to do an async drag + if (SUCCEEDED(aDataObj->QueryInterface(IID_IAsyncOperation, + getter_AddRefs(pAsyncOp)))) { + pAsyncOp->SetAsyncMode(VARIANT_TRUE); + } else { + NS_NOTREACHED("When did our data object stop being async"); } // Call the native D&D method HRESULT res = ::DoDragDrop(aDataObj, mNativeDragSrc, effects, &winDropRes); - if (isAsyncAvailable) - { - // if dragging async - // check for async operation - BOOL isAsync = FALSE; - if (pAsyncOp) - { - pAsyncOp->InOperation(&isAsync); - if (!isAsync) - aDataObj->Release(); - } - } - // In cases where the drop operation completed outside the application, update // the source node's nsIDOMNSDataTransfer dropEffect value so it is up to date. if (!mSentLocalDropEvent) {