fixed a crash where a scene was removed : the compactCache method has no more sense now that we load each scene to create a view on it (thumbnail views)

preferencesAboutTextFull
Clément Fauconnier 7 years ago
parent 75ecc33bcf
commit 1f9e6bd8bb
  1. 40
      src/core/UBSceneCache.cpp
  2. 2
      src/core/UBSceneCache.h

@ -81,11 +81,6 @@ void UBSceneCache::insert (UBDocumentProxy* proxy, int pageIndex, UBGraphicsScen
}
else
{
if (mCachedSceneCount >= UBSettings::settings()->pageCacheSize->get().toInt())
{
compactCache();
}
QHash<UBSceneCacheID, UBGraphicsScene*>::insert(key, scene);
mCachedKeyFIFO.enqueue(key);
@ -231,41 +226,6 @@ void UBSceneCache::internalMoveScene(UBDocumentProxy* proxy, int sourceIndex, in
}
}
void UBSceneCache::compactCache()
{
bool foundUnusedScene = false;
int count = 0;
do
{
if (!mCachedKeyFIFO.isEmpty())
{
const UBSceneCacheID nextKey = mCachedKeyFIFO.dequeue();
if (QHash<UBSceneCacheID, UBGraphicsScene*>::contains(nextKey))
{
UBGraphicsScene* scene = QHash<UBSceneCacheID, UBGraphicsScene*>::value(nextKey);
if (scene && scene->views().size() == 0)
{
removeScene(nextKey.documentProxy, nextKey.pageIndex);
foundUnusedScene = true;
}
else
{
mCachedKeyFIFO.enqueue(nextKey);
}
}
}
count++;
}
while (!foundUnusedScene && count < mCachedKeyFIFO.size());
}
void UBSceneCache::dumpCacheContent()
{
foreach(UBSceneCacheID key, keys())

@ -107,8 +107,6 @@ class UBSceneCache : public QHash<UBSceneCacheID, UBGraphicsScene*>
void dumpCacheContent();
void compactCache();
int mCachedSceneCount;
QQueue<UBSceneCacheID> mCachedKeyFIFO;

Loading…
Cancel
Save