From 9acd4061ccc2ff497cca8e18baa4052beb073da3 Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 2 Mar 2013 17:04:17 +0100 Subject: [PATCH 1/2] Fix dangling static references in mShared --- apps/openmw/mwworld/store.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 5fad63ff5..52120ed0e 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -187,6 +187,15 @@ namespace MWWorld T item; item.mId = Misc::StringUtils::lowerCase(id); + // delete from static part of shared + typename std::vector::iterator sharedit = mShared.begin(); + for (; sharedit != (mShared.begin()+mStatic.size()); ++sharedit) { + if((*sharedit)->mId == item.mId) { + mShared.erase(sharedit); + break; + } + } + typename std::map::iterator it = mStatic.find(item.mId); if (it != mStatic.end() && Misc::StringUtils::ciEqual(it->second.mId, id)) { From dde43e8c87430c98e52e4aa88186a57ebdde9620 Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 2 Mar 2013 21:46:31 +0100 Subject: [PATCH 2/2] Some cleanup --- apps/openmw/mwworld/store.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 52120ed0e..586e407ff 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -187,11 +187,11 @@ namespace MWWorld T item; item.mId = Misc::StringUtils::lowerCase(id); - // delete from static part of shared - typename std::vector::iterator sharedit = mShared.begin(); - for (; sharedit != (mShared.begin()+mStatic.size()); ++sharedit) { - if((*sharedit)->mId == item.mId) { - mShared.erase(sharedit); + // delete from the static part of mShared + typename std::vector::iterator sharedIter = mShared.begin(); + for (; sharedIter != (mShared.begin()+mStatic.size()); ++sharedIter) { + if((*sharedIter)->mId == item.mId) { + mShared.erase(sharedIter); break; } }