[Orxonox-commit 1104] r5825 - code/branches/core5/src/libraries/core
landauf at orxonox.net
landauf at orxonox.net
Mon Sep 28 20:59:34 CEST 2009
Author: landauf
Date: 2009-09-28 20:59:34 +0200 (Mon, 28 Sep 2009)
New Revision: 5825
Modified:
code/branches/core5/src/libraries/core/WeakPtr.h
Log:
small fix in WeakPtr
Modified: code/branches/core5/src/libraries/core/WeakPtr.h
===================================================================
--- code/branches/core5/src/libraries/core/WeakPtr.h 2009-09-28 15:50:31 UTC (rev 5824)
+++ code/branches/core5/src/libraries/core/WeakPtr.h 2009-09-28 18:59:34 UTC (rev 5825)
@@ -140,6 +140,11 @@
inline void swap(WeakPtr& other)
{
+ if (this->base_)
+ this->base_->unregisterWeakPtr(this);
+ if (other.base_)
+ other.base_->unregisterWeakPtr(&other);
+
{
T* temp = this->pointer_;
this->pointer_ = other.pointer_;
@@ -150,6 +155,11 @@
this->base_ = other.base_;
other.base_ = temp;
}
+
+ if (this->base_)
+ this->base_->registerWeakPtr(this);
+ if (other.base_)
+ other.base_->registerWeakPtr(&other);
}
inline void reset()
@@ -170,7 +180,8 @@
private:
inline void objectDeleted()
{
- this->reset();
+ this->base_ = 0;
+ this->pointer_ = 0;
if (this->callback_)
(*this->callback_)();
}
More information about the Orxonox-commit
mailing list