Fix ObjectBase's move constructor not setting handle to nullptr
This caused a crash because if handle was set to garbage then the move-constructor would try to call the Release function on it.
This commit is contained in:
parent
b2b495b5aa
commit
a0a9f633ce
|
@ -58,8 +58,7 @@ namespace nxt {
|
|||
template<typename Derived, typename CType>
|
||||
class ObjectBase {
|
||||
public:
|
||||
ObjectBase(): handle(nullptr) {
|
||||
}
|
||||
ObjectBase() = default;
|
||||
ObjectBase(CType handle): handle(handle) {
|
||||
if (handle) Derived::NxtReference(handle);
|
||||
}
|
||||
|
@ -71,14 +70,13 @@ namespace nxt {
|
|||
Derived& operator=(ObjectBase const& other) = delete;
|
||||
|
||||
ObjectBase(ObjectBase&& other) {
|
||||
Derived::NxtRelease(handle);
|
||||
handle = other.handle;
|
||||
other.handle = 0;
|
||||
}
|
||||
Derived& operator=(ObjectBase&& other) {
|
||||
if (&other == this) return static_cast<Derived&>(*this);
|
||||
|
||||
Derived::NxtRelease(handle);
|
||||
if (handle) Derived::NxtRelease(handle);
|
||||
handle = other.handle;
|
||||
other.handle = 0;
|
||||
|
||||
|
@ -106,7 +104,7 @@ namespace nxt {
|
|||
}
|
||||
|
||||
protected:
|
||||
CType handle;
|
||||
CType handle = nullptr;
|
||||
};
|
||||
|
||||
{% macro render_cpp_method_declaration(type, method) %}
|
||||
|
|
Loading…
Reference in New Issue