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:
parent
6558de636e
commit
797efbc15b
1 changed files with 18 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue