From 1098b0f5ba3284e1ac5003069c7c3d19417c542b Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Fri, 25 Sep 2015 16:17:27 +0100 Subject: [PATCH] Bug 1196144 - source window disappearance still breaks downloading to custom directories on windows, r=felipe --HG-- extra : commitid : BEPBh9mXgLl extra : rebase_source : c8ba4642f694c163355483cdcaba189c864cea8b --- toolkit/mozapps/downloads/nsHelperAppDlg.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 186fcf15a8c3..cc4903cc0b60 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -228,7 +228,21 @@ nsUnknownContentTypeDialog.prototype = { // because the original one is definitely gone (and nsIFilePicker doesn't like // a null parent): gDownloadLastDir = this._mDownloadDir; - parent = Services.wm.getMostRecentWindow(""); + let windowsEnum = Services.wm.getEnumerator(""); + while (windowsEnum.hasMoreElements()) { + let someWin = windowsEnum.getNext(); + // We need to make sure we don't end up with this dialog, because otherwise + // that's going to go away when the user clicks "Save", and that breaks the + // windows file picker that's supposed to show up if we let the user choose + // where to save files... + if (someWin != this.mDialog) { + parent = someWin; + } + } + if (!parent) { + Cu.reportError("No candidate parent windows were found for the save filepicker." + + "This should never happen."); + } } Task.spawn(function() {