From 22491e14911a00867a7ac87d9959918c9a16f25a Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 27 Aug 2014 19:00:47 +0200 Subject: [PATCH] WebPositive: Fix build I'm not so happy with this solution, but I'm out of ideas for a better one. --- src/apps/webpositive/DownloadProgressView.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/apps/webpositive/DownloadProgressView.cpp b/src/apps/webpositive/DownloadProgressView.cpp index 59cb172f56..1ab36907a1 100644 --- a/src/apps/webpositive/DownloadProgressView.cpp +++ b/src/apps/webpositive/DownloadProgressView.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include +#include "BrowserWindow.h" #include "WebDownload.h" #include "WebPage.h" #include "StringForSize.h" @@ -403,8 +405,20 @@ DownloadProgressView::MessageReceived(BMessage* message) break; } case RESTART_DOWNLOAD: - BWebPage::RequestDownload(fURL); + { + // We can't create a download without a full web context (mainly + // because it needs to access the cookie jar), and when we get here + // the original context is long gone (possibly the browser was + // restarted). So we create a new window to restart the download + // in a fresh context. + // FIXME this has of course the huge downside of leaving the new + // window open with a blank page. I can't think of a better + // solution right now... + BMessage* request = new BMessage(NEW_WINDOW); + request->AddString("url", fURL); + be_app->PostMessage(request); break; + } case CANCEL_DOWNLOAD: CancelDownload();