diff options
author | Arno <am@disconnect.de> | 2011-08-22 18:24:13 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2011-08-22 18:24:13 +0200 |
commit | 50783b0819531087266c626fa6066e8233bb0692 (patch) | |
tree | abbcaa29dc5653d8e5966eddf550bcc4e7e252e0 /smglobals.cpp | |
parent | f427305bb038ab3af27fb8a1a17827732c3713f3 (diff) | |
download | SheMov-50783b0819531087266c626fa6066e8233bb0692.tar.gz SheMov-50783b0819531087266c626fa6066e8233bb0692.tar.bz2 SheMov-50783b0819531087266c626fa6066e8233bb0692.zip |
Fixes for SmGlobals::FrameCache
Don't generate duplicate screenshots when the same file is indexed in
different paths. Part of the frameCache key was the _full_ path, not
just the filename, so duplicates piled up when hovering over the same
file in the filesystem and the archive.
Added a cleanup function to SmGlobals::FrameCache. Also, just use
QFileInfo::fileName() as part of the key.
Diffstat (limited to 'smglobals.cpp')
-rw-r--r-- | smglobals.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/smglobals.cpp b/smglobals.cpp index 8e49726..62e7537 100644 --- a/smglobals.cpp +++ b/smglobals.cpp @@ -188,7 +188,8 @@ const QPair<QString, QString> SmGlobals::FrameCache::prepFrame(const QString &so if(when.isEmpty()){ when = mWhen; } - const QPair<QString, QString> source(sourceFile, when); + const QString fileName = QFileInfo(sourceFile).fileName(); + const QPair<QString, QString> source(fileName, when); if(!mFrameCache.contains(source)){ grabFrame(sourceFile, when); } @@ -211,7 +212,7 @@ void SmGlobals::FrameCache::grabFrame(const QString &sourceFile, QString when){ return; } ffmpeg.waitForFinished(); - QPair<QString, QString> pair(sourceFile, when); + QPair<QString, QString> pair(sourceInfo.fileName(), when); mFrameCache.insert(pair, tempFile.fileName()); } } @@ -231,4 +232,27 @@ void SmGlobals::FrameCache::readCache(){ QPair<QString, QString> pair(source, pos); mFrameCache.insert(pair, cacheFile); } + cleanup(); +} + +/* cleanup function for fucked up framecache: + Key was full path until recently, not just the filename, so + duplicates showed up when hovering over the same in different + paths, eg, archive or filesystem. Should be removed in the future +*/ +void SmGlobals::FrameCache::cleanup(){ + QHash<QPair<QString, QString>, QString> newFrameCache; + QHash<QPair<QString, QString>, QString>::const_iterator it = mFrameCache.constBegin(); + while(it != mFrameCache.constEnd()){ + QPair<QString, QString> key = it.key(); + QFileInfo fi(key.first); + QPair<QString, QString> newEntry(fi.fileName(), key.second); + if(!newFrameCache.contains(newEntry)){ + newFrameCache.insert(newEntry, it.value()); + }else{ + QFile::remove(it.value()); + } + ++it; + } + mFrameCache = newFrameCache; } |