summaryrefslogtreecommitdiff
path: root/include/serialize.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-12-27 21:43:19 -0500
committerAdam <Adam@anope.org>2012-12-28 10:43:30 -0500
commit379b2ccf92b6124f2026a5ec683cfc98f08e223a (patch)
tree9cec160f53a579a83950656d5978301823f4312d /include/serialize.h
parent3fb4cf56b651eb500b1bbafb14c0d328d81e1f3c (diff)
The timestamp column in SQL should actually be null sometimes, and fixed some valgrind errors with db_sql_live
Diffstat (limited to 'include/serialize.h')
-rw-r--r--include/serialize.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/include/serialize.h b/include/serialize.h
index edbf1facf..a7ac33dfa 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -258,18 +258,34 @@ class Serialize::Reference : public ReferenceBase
obj->AddReference(this);
}
- Reference(const Reference<T> &other) : ref(other.ref)
+ Reference(const Reference<T> &other) : ReferenceBase(other), ref(other.ref)
{
- if (*this)
+ if (ref && !invalid)
this->ref->AddReference(this);
}
~Reference()
{
- if (*this)
+ if (ref && !invalid)
this->ref->DelReference(this);
}
+ inline Reference<T>& operator=(const Reference<T> &other)
+ {
+ if (this != &other)
+ {
+ if (ref && !invalid)
+ this->ref->DelReference(this);
+
+ this->ref = other.ref;
+ this->invalid = other.invalid;
+
+ if (ref && !invalid)
+ this->ref->AddReference(this);
+ }
+ return *this;
+ }
+
inline operator bool() const
{
if (!this->invalid)
@@ -277,25 +293,15 @@ class Serialize::Reference : public ReferenceBase
return false;
}
- inline void operator=(T *newref)
- {
- if (*this)
- this->ref->DelReference(this);
-
- this->ref = newref;
- this->invalid = false;
-
- if (newref)
- this->ref->AddReference(this);
- }
-
inline operator T*() const
{
if (!this->invalid)
{
if (this->ref)
+ // This can invalidate me
this->ref->QueueUpdate();
- return this->ref;
+ if (!this->invalid)
+ return this->ref;
}
return NULL;
}
@@ -305,8 +311,10 @@ class Serialize::Reference : public ReferenceBase
if (!this->invalid)
{
if (this->ref)
+ // This can invalidate me
this->ref->QueueUpdate();
- return this->ref;
+ if (!this->invalid)
+ return this->ref;
}
return NULL;
}
@@ -316,8 +324,10 @@ class Serialize::Reference : public ReferenceBase
if (!this->invalid)
{
if (this->ref)
+ // This can invalidate me
this->ref->QueueUpdate();
- return this->ref;
+ if (!this->invalid)
+ return this->ref;
}
return NULL;
}