Commit 826aa922 authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Don't delete the UrlLoader too soon when opening, saving or executing

parent 79f89bb2
......@@ -215,12 +215,21 @@ void UrlLoader::performAction()
save();
break;
case OpenUrlAction::DoNothing:
done();
break;
}
}
void UrlLoader::done(KJob *job)
{
if (job) {
jobFinished(job);
}
emit finished(this);
deleteLater();
}
bool UrlLoader::serviceIsKonqueror(KService::Ptr service)
{
return service && (service->desktopEntryName() == QLatin1String("konqueror") || service->exec().trimmed().startsWith(QLatin1String("kfmclient")));
......@@ -334,7 +343,9 @@ bool UrlLoader::shouldEmbedThis() const
void UrlLoader::embed()
{
bool embedded = m_mainWindow->openView(m_mimeType, m_url, m_view, m_request);
if (!embedded) {
if (embedded) {
done();
} else {
decideOpenOrSave();
performAction();
}
......@@ -367,6 +378,8 @@ void UrlLoader::saveUrlUsingKIO(const QUrl& orig, const QUrl& dest)
job->addMetaData(QStringLiteral("cache"), QStringLiteral("cache")); // Use entry from cache if available.
KJobWidgets::setWindow(job, m_mainWindow);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
connect(job, &KJob::finished, this, [this, job](){done(job);});
job->start();
}
void UrlLoader::open()
......@@ -384,6 +397,7 @@ void UrlLoader::open()
if (m_request.tempFile) {
job->setRunFlags(KIO::ApplicationLauncherJob::DeleteTemporaryFiles);
}
connect(job, &KJob::finished, this, [this, job](){done(job);});
job->start();
}
......@@ -392,6 +406,8 @@ void UrlLoader::execute()
if (!m_openUrlJob) {
launchOpenUrlJob(false);
} else {
disconnect(m_openUrlJob, &KJob::finished, this, nullptr); //Otherwise, jobFinished will be called twice
connect(m_openUrlJob, &KJob::finished, this, [this](){done(m_openUrlJob);});
m_openUrlJob->resume();
}
}
......
......@@ -79,6 +79,7 @@ private slots:
void mimetypeDeterminedByJob(const QString &mimeType);
void jobFinished(KJob* job);
void done(KJob *job=nullptr);
private:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment