From 8b6aa624a294248c352f95e159ebe664e9f282a6 Mon Sep 17 00:00:00 2001 From: Richard Bainesly Date: Thu, 9 Jan 2025 16:06:40 -0500 Subject: [PATCH] fix fd leaks in scanPath use auto --- src/core/desktopentry.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/desktopentry.cpp b/src/core/desktopentry.cpp index 975db3b4..063aacd6 100644 --- a/src/core/desktopentry.cpp +++ b/src/core/desktopentry.cpp @@ -309,7 +309,7 @@ void DesktopEntryManager::scanPath(const QDir& dir, const QString& prefix) { auto entries = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); for (auto& entry: entries) { - if (entry.isDir()) this->scanPath(entry.path(), prefix + dir.dirName() + "-"); + if (entry.isDir()) this->scanPath(entry.absoluteFilePath(), prefix + dir.dirName() + "-"); else if (entry.isFile()) { auto path = entry.filePath(); if (!path.endsWith(".desktop")) { @@ -317,9 +317,8 @@ void DesktopEntryManager::scanPath(const QDir& dir, const QString& prefix) { continue; } - auto* file = new QFile(path); - - if (!file->open(QFile::ReadOnly)) { + auto file = QFile(path); + if (!file.open(QFile::ReadOnly)) { qCDebug(logDesktopEntry) << "Could not open file" << path; continue; } @@ -327,7 +326,7 @@ void DesktopEntryManager::scanPath(const QDir& dir, const QString& prefix) { auto id = prefix + entry.fileName().sliced(0, entry.fileName().length() - 8); auto lowerId = id.toLower(); - auto text = QString::fromUtf8(file->readAll()); + auto text = QString::fromUtf8(file.readAll()); auto* dentry = new DesktopEntry(id, this); dentry->parseEntry(text);