diff --git a/widget/nsFilePickerProxy.cpp b/widget/nsFilePickerProxy.cpp index 1d1e2278ce96..fbb3c4d389b2 100644 --- a/widget/nsFilePickerProxy.cpp +++ b/widget/nsFilePickerProxy.cpp @@ -18,6 +18,7 @@ NS_IMPL_ISUPPORTS(nsFilePickerProxy, nsIFilePicker) nsFilePickerProxy::nsFilePickerProxy() : mSelectedType(0) + , mIPCActive(false) { } @@ -40,6 +41,8 @@ nsFilePickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle, NS_ADDREF_THIS(); tabChild->SendPFilePickerConstructor(this, nsString(aTitle), aMode); + + mIPCActive = true; return NS_OK; } @@ -136,6 +139,10 @@ nsFilePickerProxy::Open(nsIFilePickerShownCallback* aCallback) mDisplayDirectory->GetPath(displayDirectory); } + if (!mIPCActive) { + return NS_ERROR_FAILURE; + } + SendOpen(mSelectedType, mAddToRecentDocs, mDefault, mDefaultExtension, mFilters, mFilterNames, displayDirectory, mOkButtonLabel); @@ -271,3 +278,14 @@ nsFilePickerProxy::GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aDomfil enumerator.forget(aDomfiles); return NS_OK; } + +void +nsFilePickerProxy::ActorDestroy(ActorDestroyReason aWhy) +{ + mIPCActive = false; + + if (mCallback) { + mCallback->Done(nsIFilePicker::returnCancel); + mCallback = nullptr; + } +} diff --git a/widget/nsFilePickerProxy.h b/widget/nsFilePickerProxy.h index 0b39f23cb074..d6c022d778c9 100644 --- a/widget/nsFilePickerProxy.h +++ b/widget/nsFilePickerProxy.h @@ -60,6 +60,9 @@ private: ~nsFilePickerProxy(); void InitNative(nsIWidget*, const nsAString&) override; + void + ActorDestroy(ActorDestroyReason aWhy) override; + nsTArray mFilesOrDirectories; nsCOMPtr mCallback; @@ -68,6 +71,8 @@ private: nsString mDefault; nsString mDefaultExtension; + bool mIPCActive; + InfallibleTArray mFilters; InfallibleTArray mFilterNames; };