mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-11-16 23:05:58 +01:00
sharedptr: decrement on destruction (#1)
if we dont decrement the sharedptr on destruction any weakptr remaining will have an impl_ with a ref of 1 and upon destruction of the weakptr it wont delete the implentation because it thinks a shared pointer still exist.
This commit is contained in:
parent
0693f9398a
commit
1f4743a1f7
1 changed files with 1 additions and 7 deletions
|
@ -169,13 +169,7 @@ namespace Hyprutils {
|
||||||
}
|
}
|
||||||
|
|
||||||
~CSharedPointer() {
|
~CSharedPointer() {
|
||||||
// we do not decrement here,
|
decrement();
|
||||||
// because we want to preserve the pointer
|
|
||||||
// in case this is the last owner.
|
|
||||||
if (impl_ && impl_->ref() == 1)
|
|
||||||
destroyImpl();
|
|
||||||
else
|
|
||||||
decrement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
|
|
Loading…
Reference in a new issue