From eeba2ac8489aa2979446e8d27b387f9d11d17ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 6 Mar 2017 13:42:00 +0100 Subject: [PATCH] Platform: proper NoCreate constructors for windowed classes. The move away from `nullptr` to NoCreate for constructing an application without creating OpenGL context was done quite some time ago for windowless application, but for some weird reason it was never done for windowed apps. Now made this consistent. The old `nullptr`-based constructor is still present, but marked as deprecated and due to be removed in some future release. --- src/Magnum/Platform/AbstractXApplication.cpp | 4 ++-- src/Magnum/Platform/AbstractXApplication.h | 3 ++- src/Magnum/Platform/AndroidApplication.cpp | 4 ++-- src/Magnum/Platform/AndroidApplication.h | 13 +++++++++++-- src/Magnum/Platform/GlfwApplication.cpp | 4 ++-- src/Magnum/Platform/GlfwApplication.h | 13 +++++++++++-- src/Magnum/Platform/GlutApplication.cpp | 4 ++-- src/Magnum/Platform/GlutApplication.h | 13 +++++++++++-- src/Magnum/Platform/GlxApplication.cpp | 2 +- src/Magnum/Platform/GlxApplication.h | 12 ++++++++++-- src/Magnum/Platform/NaClApplication.cpp | 4 ++-- src/Magnum/Platform/NaClApplication.h | 13 +++++++++++-- src/Magnum/Platform/ScreenedApplication.h | 10 +++++++++- src/Magnum/Platform/ScreenedApplication.hpp | 2 +- src/Magnum/Platform/Sdl2Application.cpp | 4 ++-- src/Magnum/Platform/Sdl2Application.h | 11 ++++++++++- src/Magnum/Platform/XEglApplication.cpp | 2 +- src/Magnum/Platform/XEglApplication.h | 12 ++++++++++-- 18 files changed, 100 insertions(+), 30 deletions(-) diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index b91716622..3c4538ae6 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -37,11 +37,11 @@ namespace Magnum { namespace Platform { -AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, const Configuration& configuration): AbstractXApplication{contextHandler, arguments, nullptr} { +AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, const Configuration& configuration): AbstractXApplication{contextHandler, arguments, NoCreate} { createContext(configuration); } -AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, std::nullptr_t): _contextHandler{contextHandler}, _context{new Context{NoCreate, arguments.argc, arguments.argv}}, _flags{Flag::Redraw} {} +AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, NoCreateT): _contextHandler{contextHandler}, _context{new Context{NoCreate, arguments.argc, arguments.argv}}, _flags{Flag::Redraw} {} void AbstractXApplication::createContext() { createContext({}); } diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index 1f160651a..4b348f107 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -41,6 +41,7 @@ #undef Status #include "Magnum/Magnum.h" +#include "Magnum/Tags.h" #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/Platform.h" @@ -171,7 +172,7 @@ class AbstractXApplication { #endif explicit AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, const Configuration& configuration); - explicit AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, std::nullptr_t); + explicit AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, NoCreateT); private: enum class Flag: unsigned int { diff --git a/src/Magnum/Platform/AndroidApplication.cpp b/src/Magnum/Platform/AndroidApplication.cpp index fadd23002..1745db7bf 100644 --- a/src/Magnum/Platform/AndroidApplication.cpp +++ b/src/Magnum/Platform/AndroidApplication.cpp @@ -57,11 +57,11 @@ AndroidApplication::LogOutput::LogOutput(): AndroidApplication::AndroidApplication(const Arguments& arguments): AndroidApplication{arguments, Configuration{}} {} #endif -AndroidApplication::AndroidApplication(const Arguments& arguments, const Configuration& configuration): AndroidApplication{arguments, nullptr} { +AndroidApplication::AndroidApplication(const Arguments& arguments, const Configuration& configuration): AndroidApplication{arguments, NoCreate} { createContext(configuration); } -AndroidApplication::AndroidApplication(const Arguments& arguments, std::nullptr_t): _state{arguments}, _context{new Context{NoCreate, 0, nullptr}} { +AndroidApplication::AndroidApplication(const Arguments& arguments, NoCreateT): _state{arguments}, _context{new Context{NoCreate, 0, nullptr}} { /* Redirect debug output to Android log */ _logOutput.reset(new LogOutput); } diff --git a/src/Magnum/Platform/AndroidApplication.h b/src/Magnum/Platform/AndroidApplication.h index 5a9b5c39e..663bce85b 100644 --- a/src/Magnum/Platform/AndroidApplication.h +++ b/src/Magnum/Platform/AndroidApplication.h @@ -34,6 +34,7 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/Tags.h" #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/Platform.h" @@ -201,8 +202,16 @@ class AndroidApplication { explicit AndroidApplication(const Arguments& arguments); #endif - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ - explicit AndroidApplication(const Arguments& arguments, std::nullptr_t); + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ + explicit AndroidApplication(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AndroidApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref AndroidApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use AndroidApplication(const Arguments&, NoCreateT) instead") explicit AndroidApplication(const Arguments& arguments, std::nullptr_t): AndroidApplication{arguments, NoCreate} {} + #endif /** @brief Copying is not allowed */ AndroidApplication(const AndroidApplication&) = delete; diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 8ee116619..2fd3b0aa6 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -47,11 +47,11 @@ static_assert(GLFW_TRUE == true && GLFW_FALSE == false, "GLFW does not have sane GlfwApplication::GlfwApplication(const Arguments& arguments): GlfwApplication{arguments, Configuration{}} {} #endif -GlfwApplication::GlfwApplication(const Arguments& arguments, const Configuration& configuration): GlfwApplication{arguments, nullptr} { +GlfwApplication::GlfwApplication(const Arguments& arguments, const Configuration& configuration): GlfwApplication{arguments, NoCreate} { createContext(configuration); } -GlfwApplication::GlfwApplication(const Arguments& arguments, std::nullptr_t): +GlfwApplication::GlfwApplication(const Arguments& arguments, NoCreateT): _context{new Context{NoCreate, arguments.argc, arguments.argv}}, _flags{Flag::Redraw} { diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index 69eb48ce8..dc81a599d 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -35,6 +35,7 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/Tags.h" #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/Platform.h" @@ -122,8 +123,16 @@ class GlfwApplication { explicit GlfwApplication(const Arguments& arguments); #endif - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ - explicit GlfwApplication(const Arguments& arguments, std::nullptr_t); + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ + explicit GlfwApplication(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief GlfwApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref GlfwApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use GlfwApplication(const Arguments&, NoCreateT) instead") explicit GlfwApplication(const Arguments& arguments, std::nullptr_t): GlfwApplication{arguments, NoCreate} {} + #endif /** @brief Copying is not allowed */ GlfwApplication(const GlfwApplication&) = delete; diff --git a/src/Magnum/Platform/GlutApplication.cpp b/src/Magnum/Platform/GlutApplication.cpp index 6fd1043c6..cf3fac654 100644 --- a/src/Magnum/Platform/GlutApplication.cpp +++ b/src/Magnum/Platform/GlutApplication.cpp @@ -39,11 +39,11 @@ GlutApplication* GlutApplication::_instance = nullptr; GlutApplication::GlutApplication(const Arguments& arguments): GlutApplication{arguments, Configuration{}} {} #endif -GlutApplication::GlutApplication(const Arguments& arguments, const Configuration& configuration): GlutApplication{arguments, nullptr} { +GlutApplication::GlutApplication(const Arguments& arguments, const Configuration& configuration): GlutApplication{arguments, NoCreate} { createContext(configuration); } -GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t): _context{new Context{NoCreate, arguments.argc, arguments.argv}} { +GlutApplication::GlutApplication(const Arguments& arguments, NoCreateT): _context{new Context{NoCreate, arguments.argc, arguments.argv}} { /* Save global instance */ _instance = this; diff --git a/src/Magnum/Platform/GlutApplication.h b/src/Magnum/Platform/GlutApplication.h index bedc3d1ff..ae3e6430b 100644 --- a/src/Magnum/Platform/GlutApplication.h +++ b/src/Magnum/Platform/GlutApplication.h @@ -33,6 +33,7 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/Tags.h" #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/Platform.h" @@ -117,8 +118,16 @@ class GlutApplication { explicit GlutApplication(const Arguments& arguments); #endif - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ - explicit GlutApplication(const Arguments& arguments, std::nullptr_t); + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ + explicit GlutApplication(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief GlutApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref GlutApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use GlutApplication(const Arguments&, NoCreateT) instead") explicit GlutApplication(const Arguments& arguments, std::nullptr_t): GlutApplication{arguments, NoCreate} {} + #endif /** @brief Copying is not allowed */ GlutApplication(const GlutApplication&) = delete; diff --git a/src/Magnum/Platform/GlxApplication.cpp b/src/Magnum/Platform/GlxApplication.cpp index d3cb3af1d..a4ebe287f 100644 --- a/src/Magnum/Platform/GlxApplication.cpp +++ b/src/Magnum/Platform/GlxApplication.cpp @@ -33,7 +33,7 @@ namespace Magnum { namespace Platform { GlxApplication::GlxApplication(const Arguments& arguments, const Configuration& configuration): AbstractXApplication(new Implementation::GlxContextHandler, arguments, configuration) {} -GlxApplication::GlxApplication(const Arguments& arguments, std::nullptr_t): AbstractXApplication(new Implementation::GlxContextHandler, arguments, nullptr) {} +GlxApplication::GlxApplication(const Arguments& arguments, NoCreateT): AbstractXApplication{new Implementation::GlxContextHandler, arguments, NoCreate} {} GlxApplication::~GlxApplication() = default; diff --git a/src/Magnum/Platform/GlxApplication.h b/src/Magnum/Platform/GlxApplication.h index 674677ed4..854dcbc04 100644 --- a/src/Magnum/Platform/GlxApplication.h +++ b/src/Magnum/Platform/GlxApplication.h @@ -88,8 +88,16 @@ class GlxApplication: public AbstractXApplication { */ explicit GlxApplication(const Arguments& arguments, const Configuration& configuration = Configuration()); - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ - explicit GlxApplication(const Arguments& arguments, std::nullptr_t); + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ + explicit GlxApplication(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief GlxApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref GlxApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use GlxApplication(const Arguments&, NoCreateT) instead") explicit GlxApplication(const Arguments& arguments, std::nullptr_t): GlxApplication{arguments, NoCreate} {} + #endif protected: /* Nobody will need to have (and delete) GlxApplication*, thus this is diff --git a/src/Magnum/Platform/NaClApplication.cpp b/src/Magnum/Platform/NaClApplication.cpp index afe153845..5ee89f7a9 100644 --- a/src/Magnum/Platform/NaClApplication.cpp +++ b/src/Magnum/Platform/NaClApplication.cpp @@ -62,11 +62,11 @@ NaClApplication::ConsoleDebugOutput::ConsoleDebugOutput(pp::Instance* instance): NaClApplication::NaClApplication(const Arguments& arguments): NaClApplication{arguments, Configuration{}} {} #endif -NaClApplication::NaClApplication(const Arguments& arguments, const Configuration& configuration): NaClApplication{arguments, nullptr} { +NaClApplication::NaClApplication(const Arguments& arguments, const Configuration& configuration): NaClApplication{arguments, NoCreate} { createContext(configuration); } -NaClApplication::NaClApplication(const Arguments& arguments, std::nullptr_t): Instance(arguments), Graphics3DClient(this), MouseLock(this) { +NaClApplication::NaClApplication(const Arguments& arguments, NoCreateT): Instance(arguments), Graphics3DClient(this), MouseLock(this) { _debugOutput.reset(new ConsoleDebugOutput{this}); } diff --git a/src/Magnum/Platform/NaClApplication.h b/src/Magnum/Platform/NaClApplication.h index 29c22ef4b..6f1e84c70 100644 --- a/src/Magnum/Platform/NaClApplication.h +++ b/src/Magnum/Platform/NaClApplication.h @@ -44,6 +44,7 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/Tags.h" #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/Platform.h" @@ -215,8 +216,16 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public explicit NaClApplication(const Arguments& arguments); #endif - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ - explicit NaClApplication(const Arguments& arguments, std::nullptr_t); + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ + explicit NaClApplication(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief NaClApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref NaClApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use NaClApplication(const Arguments&, NoCreateT) instead") explicit NaClApplication(const Arguments& arguments, std::nullptr_t): NaClApplication{arguments, NoCreate} {} + #endif /** @brief Copying is not allowed */ NaClApplication(const NaClApplication&) = delete; diff --git a/src/Magnum/Platform/ScreenedApplication.h b/src/Magnum/Platform/ScreenedApplication.h index ae664823f..23554424b 100644 --- a/src/Magnum/Platform/ScreenedApplication.h +++ b/src/Magnum/Platform/ScreenedApplication.h @@ -120,7 +120,15 @@ template class BasicScreenedApplication: public Application, * with @ref Sdl2Application::createContext() "createContext()" or * @ref Sdl2Application::tryCreateContext() "tryCreateContext()". */ - explicit BasicScreenedApplication(const typename Application::Arguments& arguments, std::nullptr_t); + explicit BasicScreenedApplication(const typename Application::Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief BasicScreenedApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref BasicScreenedApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use BasicScreenedApplication(const Arguments&, NoCreateT) instead") explicit BasicScreenedApplication(const typename Application::Arguments& arguments, std::nullptr_t): BasicScreenedApplication{arguments, NoCreate} {} + #endif /** * @brief Add screen to application diff --git a/src/Magnum/Platform/ScreenedApplication.hpp b/src/Magnum/Platform/ScreenedApplication.hpp index b2b1c43a9..01efef8e5 100644 --- a/src/Magnum/Platform/ScreenedApplication.hpp +++ b/src/Magnum/Platform/ScreenedApplication.hpp @@ -45,7 +45,7 @@ template void BasicScreen::mouseMoveEvent(MouseM template BasicScreenedApplication::BasicScreenedApplication(const typename Application::Arguments& arguments, const typename Application::Configuration& configuration): Application(arguments, configuration) {} -template BasicScreenedApplication::BasicScreenedApplication(const typename Application::Arguments& arguments, std::nullptr_t): Application(arguments, nullptr) {} +template BasicScreenedApplication::BasicScreenedApplication(const typename Application::Arguments& arguments, NoCreateT): Application(arguments, NoCreate) {} template BasicScreenedApplication::~BasicScreenedApplication() = default; diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index b7f731e78..16936915a 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -69,11 +69,11 @@ void Sdl2Application::staticMainLoop() { Sdl2Application::Sdl2Application(const Arguments& arguments): Sdl2Application{arguments, Configuration{}} {} #endif -Sdl2Application::Sdl2Application(const Arguments& arguments, const Configuration& configuration): Sdl2Application{arguments, nullptr} { +Sdl2Application::Sdl2Application(const Arguments& arguments, const Configuration& configuration): Sdl2Application{arguments, NoCreate} { createContext(configuration); } -Sdl2Application::Sdl2Application(const Arguments& arguments, std::nullptr_t): _glContext{nullptr}, +Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): _glContext{nullptr}, #ifndef CORRADE_TARGET_EMSCRIPTEN _minimalLoopPeriod{0}, #endif diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 4a7e47c68..1fa12eaeb 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -35,6 +35,7 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/Tags.h" #include "Magnum/Math/Vector2.h" #include "Magnum/Platform/Platform.h" @@ -361,7 +362,15 @@ class Sdl2Application { * Unlike above, the context is not created and must be created later * with @ref createContext() or @ref tryCreateContext(). */ - explicit Sdl2Application(const Arguments& arguments, std::nullptr_t); + explicit Sdl2Application(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief Sdl2Application(const Arguments&, NoCreateT) + * @deprecated Use @ref Sdl2Application(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use Sdl2Application(const Arguments&, NoCreateT) instead") explicit Sdl2Application(const Arguments& arguments, std::nullptr_t): Sdl2Application{arguments, NoCreate} {} + #endif /** @brief Copying is not allowed */ Sdl2Application(const Sdl2Application&) = delete; diff --git a/src/Magnum/Platform/XEglApplication.cpp b/src/Magnum/Platform/XEglApplication.cpp index f250c9452..042e0764e 100644 --- a/src/Magnum/Platform/XEglApplication.cpp +++ b/src/Magnum/Platform/XEglApplication.cpp @@ -32,7 +32,7 @@ namespace Magnum { namespace Platform { XEglApplication::XEglApplication(const Arguments& arguments, const Configuration& configuration): AbstractXApplication(new Implementation::EglContextHandler, arguments, configuration) {} -XEglApplication::XEglApplication(const Arguments& arguments, std::nullptr_t): AbstractXApplication(new Implementation::EglContextHandler, arguments, nullptr) {} +XEglApplication::XEglApplication(const Arguments& arguments, NoCreateT): AbstractXApplication{new Implementation::EglContextHandler, arguments, NoCreate} {} XEglApplication::~XEglApplication() = default; diff --git a/src/Magnum/Platform/XEglApplication.h b/src/Magnum/Platform/XEglApplication.h index 8244c6db4..92dee5ebb 100644 --- a/src/Magnum/Platform/XEglApplication.h +++ b/src/Magnum/Platform/XEglApplication.h @@ -89,8 +89,16 @@ class XEglApplication: public AbstractXApplication { */ explicit XEglApplication(const Arguments& arguments, const Configuration& configuration = Configuration()); - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ - explicit XEglApplication(const Arguments& arguments, std::nullptr_t); + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ + explicit XEglApplication(const Arguments& arguments, NoCreateT); + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief XEglApplication(const Arguments&, NoCreateT) + * @deprecated Use @ref XEglApplication(const Arguments&, NoCreateT) instead. + */ + CORRADE_DEPRECATED("use XEglApplication(const Arguments&, NoCreateT) instead") explicit XEglApplication(const Arguments& arguments, std::nullptr_t): XEglApplication{arguments, NoCreate} {} + #endif protected: /* Nobody will need to have (and delete) XEglApplication*, thus this is