Bug 1343212 - FilePicker child actor must not send Open() if it has been already distroyed, r=mccr8

This commit is contained in:
Andrea Marchesini 2017-03-30 19:55:55 +02:00
parent fdef612e0c
commit 1f3049c002
2 changed files with 23 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -60,6 +60,9 @@ private:
~nsFilePickerProxy();
void InitNative(nsIWidget*, const nsAString&) override;
void
ActorDestroy(ActorDestroyReason aWhy) override;
nsTArray<mozilla::dom::OwningFileOrDirectory> mFilesOrDirectories;
nsCOMPtr<nsIFilePickerShownCallback> mCallback;
@ -68,6 +71,8 @@ private:
nsString mDefault;
nsString mDefaultExtension;
bool mIPCActive;
InfallibleTArray<nsString> mFilters;
InfallibleTArray<nsString> mFilterNames;
};