Skip to content

Commit

Permalink
fix fd leaks in scanPath
Browse files Browse the repository at this point in the history
use auto
  • Loading branch information
phonetic112 authored and outfoxxed committed Jan 10, 2025
1 parent 2c411fc commit 5be2585
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/core/desktopentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,25 +309,24 @@ 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")) {
qCDebug(logDesktopEntry) << "Skipping file" << path << "as it has no .desktop extension";
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;
}

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

Expand Down

0 comments on commit 5be2585

Please sign in to comment.