From 194547d321a327d6bea549a2aed047169973883b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 21 Sep 2016 13:35:25 -0400 Subject: Another small fix to try and correct the memory leak. --- src-qt5/core/libLumina/LuminaXDG.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src-qt5/core') diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index a32273c0..b57738c1 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -56,32 +56,34 @@ void XDGDesktopList::updateList(){ path = dir.absoluteFilePath(apps[a]); if(files.contains(path) && (files.value(path).lastRead>QFileInfo(path).lastModified()) ){ //Re-use previous data for this file (nothing changed) - dFile = files[path]; + found << files[path].name; //keep track of which files were already found ok=true; }else{ ok=false; + if(files.contains(path)){ files.remove(path); } dFile = LXDG::loadDesktopFile(path,ok); //will change the "ok" variable as needed appschanged = true; //flag that something changed - needed to load a file + if(ok && !found.contains(dFile.name)){ + if(!oldkeys.contains(path)){ newfiles << path; } //brand new file (not an update to a previously-read file) + files.insert(path, dFile); + found << dFile.name; + } } - if(ok && !found.contains(dFile.name)){ - if(!oldkeys.contains(path)){ newfiles << path; } //brand new file (not an update to a previously-read file) - else{ files.remove(path); } //just to ensure that we don't get duplicates within the Hash - files.insert(path, dFile); - found << dFile.name; - oldkeys.removeAll(path); //make sure this key does not get cleaned up later - } + oldkeys.removeAll(path); //make sure this key does not get cleaned up later } //end loop over apps } //end loop over appDirs //Save the extra info to the internal lists - if(!firstrun){ removedApps = oldkeys; }//files which were removed - if(!firstrun){ newApps = newfiles; }//files which were added + if(!firstrun){ + removedApps = oldkeys;//files which were removed + newApps = newfiles; //files which were added + } //Now go through and cleanup any old keys where the associated file does not exist anymore for(int i=0; iremovePaths(QStringList() << watcher->files() << watcher->directories()); watcher->addPaths(appDirs); if(appschanged){ emit appsUpdated(); } -- cgit