diff options
author | Johannes Tröscher <fritz_van_tom@hotmail.com> | 2011-07-26 12:07:10 +0200 |
---|---|---|
committer | Johannes Tröscher <fritz_van_tom@hotmail.com> | 2011-07-26 12:07:10 +0200 |
commit | 83fa761de592db992eb99094256fd4615330e27f (patch) | |
tree | ce45e8bb2673abef80f29729a40dc7641ffd25bd | |
parent | clean up (diff) | |
download | rekonq-83fa761de592db992eb99094256fd4615330e27f.tar.xz |
use KTemporaryFile for tempfile in viewPageSource action. REVIEW:102087
-rw-r--r-- | src/mainwindow.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c0ca149e..833e69d3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -979,25 +979,19 @@ void MainWindow::viewPageSource() if (!w) return; - KUrl url = w->url(); - QString code = w->page()->mainFrame()->toHtml(); - // find a safe file name... - QUrl tempUrl = QUrl(url.url()); - QByteArray name = tempUrl.toEncoded(QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash); - QString filePath = KStandardDirs::locateLocal("tmp", QString("code/") + name.toBase64(), true); - - QFile temp(filePath); + KTemporaryFile tmpFile; + tmpFile.setAutoRemove(false); + if (!tmpFile.open()) + return; - if (temp.open(QFile::WriteOnly | QFile::Truncate)) - { - QTextStream out(&temp); - out << code; - } + QTextStream out(&tmpFile); + out << code; + tmpFile.close(); + KUrl tmpUrl(tmpFile.fileName()); - KRun::runUrl(QString(QL1S("file://") + temp.fileName()), QL1S("text/plain"), this, false); - return; + KRun::runUrl(tmpUrl, QL1S("text/plain"), this, false); } |