Skip to content

Commit 95aba6f

Browse files
committed
resotre some logging and conflicting id checks
1 parent 41ae898 commit 95aba6f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/core/desktopentry.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,16 @@ void DesktopEntryScanner::scanDirectory(const QDir& dir, DesktopEntryScanResults
298298
this->scanDirectory(QDir(entry.absoluteFilePath()), entries);
299299
} else if (entry.isFile()) {
300300
auto path = entry.filePath();
301-
if (!path.endsWith(".desktop")) continue;
301+
if (!path.endsWith(".desktop")) {
302+
qCDebug(logDesktopEntry) << "Skipping file" << path << "as it has no .desktop extension";
303+
continue;
304+
}
302305

303306
auto file = QFile(path);
304-
if (!file.open(QFile::ReadOnly)) continue;
307+
if (!file.open(QFile::ReadOnly)) {
308+
qCDebug(logDesktopEntry) << "Could not open file" << path;
309+
continue;
310+
}
305311

306312
auto id = manager->extractIdFromPath(entry.absoluteFilePath());
307313
auto content = QString::fromUtf8(file.readAll());
@@ -429,13 +435,19 @@ void DesktopEntryManager::onScanCompleted(const DesktopEntryScanResults& scanRes
429435
dentry->parseEntry(parsed.content);
430436

431437
if (!dentry->isValid()) {
438+
qCDebug(logDesktopEntry) << "Skipping desktop entry" << parsed.id;
432439
delete dentry;
433440
continue;
434441
}
435442

443+
qCDebug(logDesktopEntry) << "Found desktop entry" << parsed.id;
444+
436445
auto lowerId = parsed.id.toLower();
437446

438-
if (newEntries.contains(parsed.id)) {
447+
auto conflictingId = newEntries.contains(parsed.id);
448+
449+
if (conflictingId) {
450+
qCDebug(logDesktopEntry) << "Replacing old entry for" << parsed.id;
439451
delete newEntries.value(parsed.id);
440452
newEntries.remove(parsed.id);
441453
newLowercaseEntries.remove(lowerId);
@@ -444,6 +456,11 @@ void DesktopEntryManager::onScanCompleted(const DesktopEntryScanResults& scanRes
444456
newEntries.insert(parsed.id, dentry);
445457

446458
if (newLowercaseEntries.contains(lowerId)) {
459+
qCInfo(logDesktopEntry).nospace()
460+
<< "Multiple desktop entries have the same lowercased id " << lowerId
461+
<< ". This can cause ambiguity when byId requests are not made with the correct case "
462+
"already.";
463+
447464
newLowercaseEntries.remove(lowerId);
448465
}
449466

0 commit comments

Comments
 (0)