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)
|
Ref& operator=(const Ref r)
|
||||||
{
|
{
|
||||||
if ( obj ) { obj->Unref_Renamed(); obj = NULL; }
|
if ( obj == r.Get() )
|
||||||
if ( (obj = r.Get()) ) obj->Refer_Renamed();
|
return *this;
|
||||||
|
if ( obj )
|
||||||
|
{
|
||||||
|
obj->Unref_Renamed();
|
||||||
|
obj = NULL;
|
||||||
|
}
|
||||||
|
if ( (obj = r.Get()) )
|
||||||
|
obj->Refer_Renamed();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class U>
|
template <class U>
|
||||||
Ref operator=(const Ref<U> r)
|
Ref operator=(const Ref<U> r)
|
||||||
{
|
{
|
||||||
if ( obj ) { obj->Unref_Renamed(); obj = NULL; }
|
if ( obj == r.Get() )
|
||||||
if ( (obj = r.Get()) ) obj->Refer_Renamed();
|
return *this;
|
||||||
|
if ( obj )
|
||||||
|
{
|
||||||
|
obj->Unref_Renamed();
|
||||||
|
obj = NULL;
|
||||||
|
}
|
||||||
|
if ( (obj = r.Get()) )
|
||||||
|
obj->Refer_Renamed();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue