File dont-use-kio-copy.patch of Package ksudoku

From 40e80d73866634c954dce212f2da43cd0fdce8d6 Mon Sep 17 00:00:00 2001
From: Jeremy Whiting <jpwhiting@kde.org>
Date: Tue, 19 Mar 2019 20:23:11 -0600
Subject: [PATCH] Don't use KIO copy and QTemporaryFile to load xml definition
 files.

Since files are usually (maybe always?) local anyway, there's not
much reason to copy the file to a temporary file.
This also fixes QDomDocument::setContent failing on an empty file
when the QTemporaryFile is somehow empty after the copy has finished.

Reviewed by: Ian Wadham <iandw.au@gmail.com>
BUG: 405422
---
 src/gui/serializer.cpp | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/gui/serializer.cpp b/src/gui/serializer.cpp
index 0ded5f6..7ebd4bf 100644
--- a/src/gui/serializer.cpp
+++ b/src/gui/serializer.cpp
@@ -404,23 +404,18 @@ SKGraph *Serializer::loadCustomShape(const QUrl& url, QWidget* window, QString&
 		return nullptr;
 	}
 	QDomDocument doc;
+	QFile file(url.toLocalFile());
 
-	QTemporaryFile tmpFile;
-	if ( !tmpFile.open() ) {
-		errorMsg = i18n("Unable to create temporary file.");
-		return nullptr;
-	}
-	KIO::FileCopyJob *downloadJob = KIO::file_copy(url, QUrl::fromLocalFile(tmpFile.fileName()), -1, KIO::Overwrite);
-	KJobWidgets::setWindow(downloadJob, window);
-	downloadJob->exec();
-
-	if( downloadJob->error() ) {
-		errorMsg = i18n("Unable to download file.");
+	if ( !file.open(QIODevice::ReadOnly) ) {
+		errorMsg = i18n("Unable to open file.");
 		return nullptr;
 	}
 
 	int errorLine;
-	if(!doc.setContent(&tmpFile, 0, &errorLine)) {
+	int errorColumn;
+	QString errorMessage;
+	if(!doc.setContent(&file, &errorMessage, &errorLine, &errorColumn)) {
+		qDebug() << "Error " << errorMessage << " from line " << errorLine << ":" << errorColumn << " from file " << url.toString();
 		errorMsg = i18n("Cannot read XML file on line %1", errorLine);
 
 		return nullptr;
openSUSE Build Service is sponsored by