From 217ea0c7b4b3abbc0b6a287ee403c13493f1435e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 2 Aug 2019 13:48:45 +0200 Subject: [PATCH] Platform: clearer asserts for ScreenedApplication. This was asserted already in LinkedList, but there it's very disconnected from the actual screen APIs and thus confusing. --- src/Magnum/Platform/ScreenedApplication.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Magnum/Platform/ScreenedApplication.hpp b/src/Magnum/Platform/ScreenedApplication.hpp index 3ec90ec9d..e2ef62e1a 100644 --- a/src/Magnum/Platform/ScreenedApplication.hpp +++ b/src/Magnum/Platform/ScreenedApplication.hpp @@ -149,6 +149,9 @@ template BasicScreenedApplication::BasicScreened template BasicScreenedApplication::~BasicScreenedApplication() = default; template BasicScreenedApplication& BasicScreenedApplication::addScreen(BasicScreen& screen) { + CORRADE_ASSERT(!screen.application(), + "Platform::ScreenedApplication::addScreen(): screen already added to an application", *this); + /* A subset of this (except focusEvent()) is done in BasicScreen(BasicScreenedApplication&, PropagatedEvents) as well. Keep in sync. */ @@ -159,6 +162,9 @@ template BasicScreenedApplication& BasicScreened } template BasicScreenedApplication& BasicScreenedApplication::removeScreen(BasicScreen& screen) { + CORRADE_ASSERT(screen.application() == this, + "Platform::ScreenedApplication::removeScreen(): screen not owned by this application", *this); + screen.blurEvent(); Containers::LinkedList>::erase(&screen); Application::redraw(); @@ -166,6 +172,9 @@ template BasicScreenedApplication& BasicScreened } template BasicScreenedApplication& BasicScreenedApplication::focusScreen(BasicScreen& screen) { + CORRADE_ASSERT(screen.application() == this, + "Platform::ScreenedApplication::focusScreen(): screen not owned by this application", *this); + /* Already focused, nothing to do */ if(screens().first() == &screen) return *this;