mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Update User.hpp
This commit is contained in:
parent
e3c32e4788
commit
0487f26865
@ -56,11 +56,7 @@ struct DpUser
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpUser() noexcept
|
~DpUser() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -71,14 +67,24 @@ struct DpUser
|
|||||||
DpUser & operator = (DpUser && o) noexcept
|
DpUser & operator = (DpUser && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
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.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user