From fabbb99722ac9bbd8eedb26b7901646ce1655f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 20 Nov 2012 09:44:50 +0100 Subject: [PATCH] NaClApplication: fix improper assertion. Apparently input events can be processed during buffer swapping. Now asserting that callback from buffer swap is not called during input event processing (which shouldn't, as both functions should be called in the same thread). --- src/Platform/NaClApplication.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Platform/NaClApplication.cpp b/src/Platform/NaClApplication.cpp index c8af5f34e..06a6a3c56 100644 --- a/src/Platform/NaClApplication.cpp +++ b/src/Platform/NaClApplication.cpp @@ -79,8 +79,7 @@ void NaClApplication::DidChangeView(const pp::View& view) { } bool NaClApplication::HandleInputEvent(const pp::InputEvent& event) { - /* Assume everything is properly sequential here */ - CORRADE_INTERNAL_ASSERT(!(flags & Flag::SwapInProgress)); + Flags tmpFlags = flags; switch(event.GetType()) { case PP_INPUTEVENT_TYPE_KEYDOWN: @@ -112,12 +111,15 @@ bool NaClApplication::HandleInputEvent(const pp::InputEvent& event) { default: return false; } - /* Not need to redraw => assume the event was ignored */ - if(!(flags & Flag::Redraw)) return false; + /* Assume everything is properly sequential here */ + CORRADE_INTERNAL_ASSERT((tmpFlags & Flag::SwapInProgress) == (flags & Flag::SwapInProgress)); + + /* Redraw, if it won't be handled after swap automatically */ + if((flags & Flag::Redraw) && !(flags & Flag::SwapInProgress)) { + flags &= ~Flag::Redraw; + drawEvent(); + } - /* Redraw */ - flags &= ~Flag::Redraw; - drawEvent(); return true; }