From 8eac6096dca5a03b4520017585d6a810a564a793 Mon Sep 17 00:00:00 2001 From: April & May & June Date: Fri, 28 Nov 2025 22:40:07 +0800 Subject: [PATCH] fix: fix error on Archlinux build Those are mostly nodiscard errors. Simply add some assertions. --- src/common/ConfigReader.cpp | 6 ++++-- src/common/MessageHandler.h | 12 ++++++++---- src/daemon/TreelandConnector.cpp | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/common/ConfigReader.cpp b/src/common/ConfigReader.cpp index e37d497..00baf75 100644 --- a/src/common/ConfigReader.cpp +++ b/src/common/ConfigReader.cpp @@ -281,7 +281,8 @@ namespace DDM { // loading and checking phase QFile file(m_path); - file.open(QIODevice::ReadOnly); // first just for reading + bool ok = file.open(QIODevice::ReadOnly); // first just for reading + Q_ASSERT(ok); while (!file.atEnd()) { const QString line = QString::fromUtf8(file.readLine()); // get rid of comments first @@ -350,7 +351,8 @@ namespace DDM { // rewrite the whole thing only if there are changes if (changed) { - file.open(QIODevice::WriteOnly | QIODevice::Truncate); + bool ok = file.open(QIODevice::WriteOnly | QIODevice::Truncate); + Q_ASSERT(ok); for (const ConfigSection *s : sectionOrder) file.write(sectionData.value(s)); diff --git a/src/common/MessageHandler.h b/src/common/MessageHandler.h index 5c0fe9f..5e5244e 100644 --- a/src/common/MessageHandler.h +++ b/src/common/MessageHandler.h @@ -74,8 +74,10 @@ namespace DDM { // Try to open the log file if we're not outputting to a terminal if (!file.isOpen() && !isatty(STDERR_FILENO)) { - if (!file.open(QFile::Append | QFile::WriteOnly)) - file.open(QFile::Truncate | QFile::WriteOnly); + if (!file.open(QFile::Append | QFile::WriteOnly)) { + bool ok = file.open(QFile::Truncate | QFile::WriteOnly); + Q_ASSERT(ok); + } // If we can't open the file, create it in a writable location // It will look spmething like ~/.local/share/$appname/ddm.log @@ -83,8 +85,10 @@ namespace DDM { if (!file.isOpen()) { QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/ddm.log")); - if (!file.open(QFile::Append | QFile::WriteOnly)) - file.open(QFile::Truncate | QFile::WriteOnly); + if (!file.open(QFile::Append | QFile::WriteOnly)) { + bool ok = file.open(QFile::Truncate | QFile::WriteOnly); + Q_ASSERT(ok); + } } } diff --git a/src/daemon/TreelandConnector.cpp b/src/daemon/TreelandConnector.cpp index 1056427..3c1cf18 100644 --- a/src/daemon/TreelandConnector.cpp +++ b/src/daemon/TreelandConnector.cpp @@ -128,7 +128,8 @@ bool TreelandConnector::isConnected() { } void TreelandConnector::setPrivateObject(struct treeland_ddm *ddm) { - if (m_ddm) delete m_ddm; + if (m_ddm) + treeland_ddm_destroy(m_ddm); m_ddm = ddm; }