forked from teamnwah/openmw-tes3coop
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)
|
void CellPreloader::updateCache(double timestamp)
|
||||||
{
|
{
|
||||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end();)
|
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end();)
|
||||||
{
|
{
|
||||||
if (mPreloadCells.size() >= mMinCacheSize && it->second.mTimeStamp < timestamp - mExpiryDelay)
|
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++);
|
mPreloadCells.erase(it++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,6 +37,8 @@ namespace MWWorld
|
||||||
|
|
||||||
void notifyLoaded(MWWorld::CellStore* cell);
|
void notifyLoaded(MWWorld::CellStore* cell);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
/// Removes preloaded cells that have not had a preload request for a while.
|
/// Removes preloaded cells that have not had a preload request for a while.
|
||||||
void updateCache(double timestamp);
|
void updateCache(double timestamp);
|
||||||
|
|
||||||
|
|
|
@ -315,13 +315,15 @@ namespace MWWorld
|
||||||
mPreloader->notifyLoaded(cell);
|
mPreloader->notifyLoaded(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::changeToVoid()
|
void Scene::clear()
|
||||||
{
|
{
|
||||||
CellStoreCollection::iterator active = mActiveCells.begin();
|
CellStoreCollection::iterator active = mActiveCells.begin();
|
||||||
while (active!=mActiveCells.end())
|
while (active!=mActiveCells.end())
|
||||||
unloadCell (active++);
|
unloadCell (active++);
|
||||||
assert(mActiveCells.empty());
|
assert(mActiveCells.empty());
|
||||||
mCurrentCell = NULL;
|
mCurrentCell = NULL;
|
||||||
|
|
||||||
|
mPreloader->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::playerMoved(const osg::Vec3f &pos)
|
void Scene::playerMoved(const osg::Vec3f &pos)
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace MWWorld
|
||||||
///< Move to exterior cell.
|
///< Move to exterior cell.
|
||||||
/// @param changeEvent Set cellChanged flag?
|
/// @param changeEvent Set cellChanged flag?
|
||||||
|
|
||||||
void changeToVoid();
|
void clear();
|
||||||
///< Change into a void
|
///< Change into a void
|
||||||
|
|
||||||
void markCellAsUnchanged();
|
void markCellAsUnchanged();
|
||||||
|
|
|
@ -290,7 +290,7 @@ namespace MWWorld
|
||||||
mProjectileManager->clear();
|
mProjectileManager->clear();
|
||||||
mLocalScripts.clear();
|
mLocalScripts.clear();
|
||||||
|
|
||||||
mWorldScene->changeToVoid();
|
mWorldScene->clear();
|
||||||
|
|
||||||
mStore.clearDynamic();
|
mStore.clearDynamic();
|
||||||
mStore.setUp();
|
mStore.setUp();
|
||||||
|
|
Loading…
Reference in a new issue