mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Update Role.hpp
This commit is contained in:
parent
0487f26865
commit
87cb6a2cba
@ -59,11 +59,7 @@ struct DpRole
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~DpRole() noexcept
|
||||
{
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
}
|
||||
~DpRole() noexcept { Cleanup(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator (disabled).
|
||||
*/
|
||||
@ -74,14 +70,24 @@ struct DpRole
|
||||
DpRole & operator = (DpRole && o) noexcept
|
||||
{
|
||||
if (this != &o) {
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
Cleanup();
|
||||
// Transfer members values
|
||||
mPtr = std::move(o.mPtr);
|
||||
mOwned = o.mOwned;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Release any referenced resources and default to an empty/invalid state.
|
||||
*/
|
||||
void Cleanup()
|
||||
{
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) {
|
||||
// Not our job, simply forget about it
|
||||
[[maybe_unused]] auto p = mPtr.release();
|
||||
} else mPtr.reset(); // We own this so delete the instance
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user