diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index f5e0e661f..cb2b2236c 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -203,7 +203,7 @@ struct TransientContext { if (resourceCount == 0) { - context = std::make_unique(); + context.emplace(); } else if (!currentContext) { @@ -239,14 +239,14 @@ struct TransientContext // Member data //////////////////////////////////////////////////////////// unsigned int referenceCount{}; - std::unique_ptr context; + std::optional context; std::optional> sharedContextLock; bool useSharedContext{}; }; // This per-thread variable tracks if and how a transient // context is currently being used on the current thread -thread_local std::unique_ptr transientContext; +thread_local std::optional transientContext; // Supported OpenGL extensions std::vector extensions; @@ -408,8 +408,8 @@ void GlContext::acquireTransientContext() // If this is the first TransientContextLock on this thread // construct the state object - if (!transientContext) - transientContext = std::make_unique(); + if (!transientContext.has_value()) + transientContext.emplace(); // Increase the reference count ++transientContext->referenceCount; @@ -426,7 +426,7 @@ void GlContext::releaseTransientContext() std::lock_guard lock(mutex); // Make sure a matching acquireTransientContext() was called - assert(transientContext); + assert(transientContext.has_value()); // Decrease the reference count --transientContext->referenceCount;