diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 296a8f6e8..458bea2d9 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -543,10 +543,24 @@ Context::Context(void functionLoader()) { Renderer::initializeContextBasedFunctionality(); } +Context::Context(Context&& other): _version{std::move(other._version)}, + #ifndef MAGNUM_TARGET_WEBGL + _flags{std::move(other._flags)}, + #endif + _extensionRequiredVersion{std::move(other._extensionRequiredVersion)}, + _extensionStatus{std::move(other._extensionStatus)}, + _supportedExtensions{std::move(other._supportedExtensions)}, + _state{std::move(other._state)}, + _detectedDrivers{std::move(other._detectedDrivers)} +{ + other._state = nullptr; + if(_current == &other) _current = this; +} + Context::~Context() { - CORRADE_ASSERT(_current == this, "Context: Cannot destroy context which is not currently active", ); delete _state; - _current = nullptr; + + if(_current == this) _current = nullptr; } std::vector Context::shadingLanguageVersionStrings() const { diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 41dc783d8..c4bdfd876 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -210,15 +210,15 @@ class MAGNUM_EXPORT Context { /** @brief Copying is not allowed */ Context(const Context&) = delete; - /** @brief Moving is not allowed */ - Context(Context&&) = delete; + /** @brief Move constructor */ + Context(Context&& other); ~Context(); /** @brief Copying is not allowed */ Context& operator=(const Context&) = delete; - /** @brief Moving is not allowed */ + /** @brief Move assignment is not allowed */ Context& operator=(Context&&) = delete; /** @brief Current context */