Commit 9849aca3 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Fix opening saved games

Don't try to download to a temp file just to feed it to QDomDocument.

Just download the file to a bytearray and use that

BUGS: 407768
parent 3ecebabf
......@@ -32,6 +32,7 @@
#include <QTemporaryFile>
#include <KIO/FileCopyJob>
#include <KIO/StoredTransferJob>
#include <KJobWidgets>
#include <KLocalizedString>
......@@ -438,12 +439,7 @@ Game Serializer::load(const QUrl& url, QWidget* window, QString& errorMsg) {
if ( url.isEmpty() ) return Game();
QDomDocument doc;
QTemporaryFile tmpFile;
if ( !tmpFile.open() ) {
errorMsg = i18n("Unable to create temporary file.");
return Game();
}
KIO::FileCopyJob *downloadJob = KIO::file_copy(url, QUrl::fromLocalFile(tmpFile.fileName()), -1, KIO::Overwrite);
KIO::StoredTransferJob *downloadJob = KIO::storedGet(url);
KJobWidgets::setWindow(downloadJob, window);
downloadJob->exec();
......@@ -453,7 +449,7 @@ Game Serializer::load(const QUrl& url, QWidget* window, QString& errorMsg) {
}
int errorLine;
if(!doc.setContent(&tmpFile, 0, &errorLine)) {
if(!doc.setContent(downloadJob->data(), 0, &errorLine)) {
errorMsg = i18n("Cannot read XML file on line %1", errorLine);
return Game();
}
......
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