Merge pull request #2072 from elsid/navmesh_tiles_cache_item_fix

Navmesh tiles cache item fix (bug #4751)
pull/541/head
Bret Curtis 6 years ago committed by GitHub
commit 401ccedb36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -56,12 +56,12 @@ namespace DetourNavigator
Value(Value&& other) Value(Value&& other)
: mOwner(other.mOwner), mIterator(other.mIterator) : mOwner(other.mOwner), mIterator(other.mIterator)
{ {
other.mIterator = ItemIterator(); other.mOwner = nullptr;
} }
~Value() ~Value()
{ {
if (mIterator != ItemIterator()) if (mOwner)
mOwner->releaseItem(mIterator); mOwner->releaseItem(mIterator);
} }
@ -69,16 +69,13 @@ namespace DetourNavigator
Value& operator =(Value&& other) Value& operator =(Value&& other)
{ {
if (mIterator == other.mIterator) if (mOwner)
return *this;
if (mIterator != ItemIterator())
mOwner->releaseItem(mIterator); mOwner->releaseItem(mIterator);
mOwner = other.mOwner; mOwner = other.mOwner;
mIterator = other.mIterator; mIterator = other.mIterator;
other.mIterator = ItemIterator(); other.mOwner = nullptr;
return *this; return *this;
} }
@ -90,7 +87,7 @@ namespace DetourNavigator
operator bool() const operator bool() const
{ {
return mIterator != ItemIterator(); return mOwner;
} }
private: private:

Loading…
Cancel
Save