From f832c8df51ab618c243c4af5fe0a9d989574d9cd Mon Sep 17 00:00:00 2001 From: Squareys Date: Sat, 25 Aug 2018 20:47:40 +0200 Subject: [PATCH] Platform: gracefully fail GlfwApplication::exec() if no window was opened Signed-off-by: Squareys --- doc/changelog.dox | 3 +++ src/Magnum/Platform/GlfwApplication.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index 2b5d0c3ea..ee7db9cc7 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -287,6 +287,9 @@ See also: - @ref Platform::GlfwApplication::InputEvent::Modifier::Super is properly reported for both left and right modifier (Windows/⌘) key instead of just the right one +- @ref Platform::GlfwApplication::exec() now asserts instead of crashing if + the constructor fails to create a window (see [mosra/magnum#192](https://github.com/mosra/magnum/issues/192), + [mosra/magnum#272](https://github.com/mosra/magnum/pull/272)) @subsection changelog-latest-docs Documentation diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 0ce6f6b98..c92881453 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -436,6 +436,8 @@ void GlfwApplication::setSwapInterval(const Int interval) { } int GlfwApplication::exec() { + CORRADE_ASSERT(_window, "Platform::GlfwApplication::exec(): no window opened", {}); + while(!glfwWindowShouldClose(_window)) { if(_flags & Flag::Redraw) { _flags &= ~Flag::Redraw;