Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/common/ConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@

// 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

Check warning on line 284 in src/common/ConfigReader.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'ok' shadows outer variable
Q_ASSERT(ok);
while (!file.atEnd()) {
const QString line = QString::fromUtf8(file.readLine());
// get rid of comments first
Expand Down Expand Up @@ -350,7 +351,8 @@

// 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));

Expand Down
12 changes: 8 additions & 4 deletions src/common/MessageHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ 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
// or for the ddm user /var/lib/ddm/.local/share/$appname/ddm.log
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);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/daemon/TreelandConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down