1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix Ref<T> self-assignment.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-09-22 17:48:22 +02:00
parent 6558de636e
commit 797efbc15b

View file

@ -64,16 +64,30 @@ public:
Ref& operator=(const Ref r)
{
if ( obj ) { obj->Unref_Renamed(); obj = NULL; }
if ( (obj = r.Get()) ) obj->Refer_Renamed();
if ( obj == r.Get() )
return *this;
if ( obj )
{
obj->Unref_Renamed();
obj = NULL;
}
if ( (obj = r.Get()) )
obj->Refer_Renamed();
return *this;
}
template <class U>
Ref operator=(const Ref<U> r)
{
if ( obj ) { obj->Unref_Renamed(); obj = NULL; }
if ( (obj = r.Get()) ) obj->Refer_Renamed();
if ( obj == r.Get() )
return *this;
if ( obj )
{
obj->Unref_Renamed();
obj = NULL;
}
if ( (obj = r.Get()) )
obj->Refer_Renamed();
return *this;
}