@@ -298,10 +298,16 @@ void DesktopEntryScanner::scanDirectory(const QDir& dir, DesktopEntryScanResults
298
298
this ->scanDirectory (QDir (entry.absoluteFilePath ()), entries);
299
299
} else if (entry.isFile ()) {
300
300
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
+ }
302
305
303
306
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
+ }
305
311
306
312
auto id = manager->extractIdFromPath (entry.absoluteFilePath ());
307
313
auto content = QString::fromUtf8 (file.readAll ());
@@ -429,13 +435,19 @@ void DesktopEntryManager::onScanCompleted(const DesktopEntryScanResults& scanRes
429
435
dentry->parseEntry (parsed.content );
430
436
431
437
if (!dentry->isValid ()) {
438
+ qCDebug (logDesktopEntry) << " Skipping desktop entry" << parsed.id ;
432
439
delete dentry;
433
440
continue ;
434
441
}
435
442
443
+ qCDebug (logDesktopEntry) << " Found desktop entry" << parsed.id ;
444
+
436
445
auto lowerId = parsed.id .toLower ();
437
446
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 ;
439
451
delete newEntries.value (parsed.id );
440
452
newEntries.remove (parsed.id );
441
453
newLowercaseEntries.remove (lowerId);
@@ -444,6 +456,11 @@ void DesktopEntryManager::onScanCompleted(const DesktopEntryScanResults& scanRes
444
456
newEntries.insert (parsed.id , dentry);
445
457
446
458
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
+
447
464
newLowercaseEntries.remove (lowerId);
448
465
}
449
466
0 commit comments