Skip to content

Commit

Permalink
sharedptr: decrement on destruction
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gulafaran committed Jun 13, 2024
1 parent 0693f93 commit 27b2482
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions include/hyprutils/memory/SharedPtr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,7 @@ namespace Hyprutils {
}

~CSharedPointer() {
// we do not decrement here,
// because we want to preserve the pointer
// in case this is the last owner.
if (impl_ && impl_->ref() == 1)
destroyImpl();
else
decrement();
decrement();
}

template <typename U>
Expand Down

0 comments on commit 27b2482

Please sign in to comment.