Commit d412ca62 authored by David Faure's avatar David Faure
Browse files

Remember part URL to delete the tempfile even if the user used save as.

Summary:
Using the part URL at closing time is really dangerous: if the user used
"save as" (e.g. for an embedded PDF), we'll be deleting the file that
the user just saved!!

BUG: 402529

Test Plan:
launch ARK and open a ZIP file containing a PDF, click on the PDF,
an embedded viewer appears. From there, use "Save As..." to save the PDF
somewhere on your local disk. Close the embedded viewer, close ark.
It doesn't delete the saved file anymore.

Reviewers: elvisangelaccio, broulik

Reviewed By: elvisangelaccio

Subscribers: kde-utils-devel, #ark

Tags: #ark

Differential Revision: https://phabricator.kde.org/D18256
parent b19a2840
......@@ -69,12 +69,11 @@ ArkViewer::~ArkViewer()
// #261785: this preview dialog is not modal, so we need to delete
// the previewed file ourselves when the dialog is closed;
const QString previewedFilePath(m_part.data()->url().toDisplayString(QUrl::PreferLocalFile));
m_part.data()->closeUrl();
if (!previewedFilePath.isEmpty()) {
QFile::remove(previewedFilePath);
if (!m_fileName.isEmpty()) {
QFile::remove(m_fileName);
}
}
......@@ -204,6 +203,7 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const QMimeType &m
m_part.data()->openUrl(QUrl::fromLocalFile(fileName));
m_part.data()->widget()->setFocus();
m_fileName = fileName;
return true;
}
......
......@@ -47,6 +47,7 @@ private:
bool viewInInternalViewer(const QString& fileName, const QMimeType& mimeType);
QPointer<KParts::ReadOnlyPart> m_part;
QString m_fileName;
};
#endif // ARKVIEWER_H
......
Markdown is supported
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