From f2c25275757909cb0c113befe80e0ec0c9e84c6f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 18:04:28 +0800 Subject: [PATCH] Use QDomDocument content method returning ParseResult Signed-off-by: Claudio Cambra Use ParseResult returning QDomDocument setContent Signed-off-by: Claudio Cambra f parseresult Signed-off-by: Claudio Cambra --- src/gui/updater/updateinfo.cpp | 10 ++++------ src/libsync/networkjobs.cpp | 7 ++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gui/updater/updateinfo.cpp b/src/gui/updater/updateinfo.cpp index 55512374a1f57..2bfb720fb63a5 100644 --- a/src/gui/updater/updateinfo.cpp +++ b/src/gui/updater/updateinfo.cpp @@ -84,13 +84,11 @@ UpdateInfo UpdateInfo::parseElement(const QDomElement &element, bool *ok) UpdateInfo UpdateInfo::parseString(const QString &xml, bool *ok) { - QString errorMsg; - int errorLine = 0, errorCol = 0; QDomDocument doc; - if (!doc.setContent(xml, false, &errorMsg, &errorLine, &errorCol)) { - qCWarning(lcUpdater).noquote().nospace() << errorMsg << " at " << errorLine << "," << errorCol - << "\n" << xml.split("\n").value(errorLine-1) << "\n" - << QString(" ").repeated(errorCol - 1) << "^\n" + if (const auto result = doc.setContent(xml); !result) { + qCWarning(lcUpdater).noquote().nospace() << result.errorMessage << " at " << result.errorLine << "," << result.errorColumn + << "\n" << xml.split("\n").value(result.errorLine - 1) << "\n" + << QString(" ").repeated(result.errorColumn - 1) << "^\n" << "->" << xml << "<-"; if (ok) *ok = false; diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 78356f8c92f3d..1cde1a2c15a00 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -663,12 +663,9 @@ bool PropfindJob::finished() if (http_result_code == 207) { // Parse DAV response auto domDocument = QDomDocument(); - auto errorMsg = QString(); - auto errorLine = -1; - auto errorColumn = -1; - if (!domDocument.setContent(reply(), true, &errorMsg, &errorLine, &errorColumn)) { - qCWarning(lcPropfindJob) << "XML parser error: " << errorMsg << errorLine << errorColumn; + if (const auto res = domDocument.setContent(reply(), QDomDocument::ParseOption::UseNamespaceProcessing); !res) { + qCWarning(lcPropfindJob) << "XML parser error: " << res.errorMessage << res.errorLine << res.errorColumn; emit finishedWithError(reply()); } else {