diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 4a653030f..4bd9ae3b9 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -495,20 +495,17 @@ Context::Context(Context&& other): _version{other._version}, _extensionRequiredVersion{Containers::NoInit}, _extensionStatus{other._extensionStatus}, _supportedExtensions{std::move(other._supportedExtensions)}, - _state{other._state}, + _state{std::move(other._state)}, _detectedDrivers{std::move(other._detectedDrivers)} { /* StaticArray is deliberately non-copyable */ for(std::size_t i = 0; i != Implementation::ExtensionCount; ++i) _extensionRequiredVersion[i] = other._extensionRequiredVersion[i]; - other._state = nullptr; if(currentContext == &other) currentContext = this; } Context::~Context() { - delete _state; - if(currentContext == this) currentContext = nullptr; } @@ -731,7 +728,7 @@ bool Context::tryCreate() { } } - _state = new Implementation::State{*this, output}; + _state.emplace(*this, output); /* Print a list of used workarounds */ if(!_driverWorkarounds.empty()) { diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 4f0a9ae8e..206673e1c 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "Magnum/Magnum.h" @@ -708,7 +709,7 @@ class MAGNUM_GL_EXPORT Context { Math::BoolVector _extensionStatus; std::vector _supportedExtensions; - Implementation::State* _state; + Containers::Pointer _state; Containers::Optional _detectedDrivers;