Fix cleanup issue

pull/185/head
scrawl 8 years ago
parent fd215caa02
commit 97ed999097

@ -210,9 +210,14 @@ namespace MWWorld
mTerrainPreloadItem->waitTillDone();
mTerrainPreloadItem = NULL;
}
mTerrainView = NULL;
if (mUpdateCacheItem)
{
mUpdateCacheItem->waitTillDone();
mUpdateCacheItem = NULL;
}
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end();++it)
it->second.mWorkItem->abort();
@ -320,10 +325,11 @@ namespace MWWorld
++it;
}
if (timestamp - mLastResourceCacheUpdate > 1.0)
if (timestamp - mLastResourceCacheUpdate > 1.0 && (!mUpdateCacheItem || mUpdateCacheItem->isDone()))
{
// the resource cache is cleared from the worker thread so that we're not holding up the main thread with delete operations
mWorkQueue->addWorkItem(new UpdateCacheItem(mResourceSystem, timestamp), true);
mUpdateCacheItem = new UpdateCacheItem(mResourceSystem, timestamp);
mWorkQueue->addWorkItem(mUpdateCacheItem, true);
mLastResourceCacheUpdate = timestamp;
}
}
@ -397,6 +403,8 @@ namespace MWWorld
return;
else
{
// TODO: provide some way of giving the preloaded view to the main thread when we enter the cell
// right now, we just use it to make sure the resources are preloaded
mTerrainPreloadPositions = positions;
mTerrainPreloadItem = new TerrainPreloadItem(mTerrainView, mTerrain, positions);
mWorkQueue->addWorkItem(mTerrainPreloadItem);

@ -106,6 +106,7 @@ namespace MWWorld
osg::ref_ptr<Terrain::View> mTerrainView;
std::vector<osg::Vec3f> mTerrainPreloadPositions;
osg::ref_ptr<SceneUtil::WorkItem> mTerrainPreloadItem;
osg::ref_ptr<SceneUtil::WorkItem> mUpdateCacheItem;
};
}

Loading…
Cancel
Save