forked from mirror/openmw-tes3mp
Add CellPreloader::clear to avoid potential dangling CellStore pointer and to more aggressively clear preload state from a previous game
This commit is contained in:
parent
0be86f69bc
commit
3f3d00ffc9
5 changed files with 26 additions and 4 deletions
|
@ -272,13 +272,31 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
void CellPreloader::clear()
|
||||
{
|
||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end();)
|
||||
{
|
||||
if (it->second.mWorkItem)
|
||||
{
|
||||
it->second.mWorkItem->abort();
|
||||
mUnrefQueue->push(it->second.mWorkItem);
|
||||
}
|
||||
|
||||
mPreloadCells.erase(it++);
|
||||
}
|
||||
}
|
||||
|
||||
void CellPreloader::updateCache(double timestamp)
|
||||
{
|
||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end();)
|
||||
{
|
||||
if (mPreloadCells.size() >= mMinCacheSize && it->second.mTimeStamp < timestamp - mExpiryDelay)
|
||||
{
|
||||
it->second.mWorkItem->abort();
|
||||
if (it->second.mWorkItem)
|
||||
{
|
||||
it->second.mWorkItem->abort();
|
||||
mUnrefQueue->push(it->second.mWorkItem);
|
||||
}
|
||||
mPreloadCells.erase(it++);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace MWWorld
|
|||
|
||||
void notifyLoaded(MWWorld::CellStore* cell);
|
||||
|
||||
void clear();
|
||||
|
||||
/// Removes preloaded cells that have not had a preload request for a while.
|
||||
void updateCache(double timestamp);
|
||||
|
||||
|
|
|
@ -315,13 +315,15 @@ namespace MWWorld
|
|||
mPreloader->notifyLoaded(cell);
|
||||
}
|
||||
|
||||
void Scene::changeToVoid()
|
||||
void Scene::clear()
|
||||
{
|
||||
CellStoreCollection::iterator active = mActiveCells.begin();
|
||||
while (active!=mActiveCells.end())
|
||||
unloadCell (active++);
|
||||
assert(mActiveCells.empty());
|
||||
mCurrentCell = NULL;
|
||||
|
||||
mPreloader->clear();
|
||||
}
|
||||
|
||||
void Scene::playerMoved(const osg::Vec3f &pos)
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace MWWorld
|
|||
///< Move to exterior cell.
|
||||
/// @param changeEvent Set cellChanged flag?
|
||||
|
||||
void changeToVoid();
|
||||
void clear();
|
||||
///< Change into a void
|
||||
|
||||
void markCellAsUnchanged();
|
||||
|
|
|
@ -290,7 +290,7 @@ namespace MWWorld
|
|||
mProjectileManager->clear();
|
||||
mLocalScripts.clear();
|
||||
|
||||
mWorldScene->changeToVoid();
|
||||
mWorldScene->clear();
|
||||
|
||||
mStore.clearDynamic();
|
||||
mStore.setUp();
|
||||
|
|
Loading…
Reference in a new issue