Skip to content

Commit

Permalink
Attempted fix for GUI2 event firing test failures
Browse files Browse the repository at this point in the history
Commit 315f849 broke the test in two ways. First, I intentionally
changed pre and post events to be passed to the target widget as well, not
only its ancestors. The test verified that the events were *not* passed to
the target widget. Fixed by adjusting the test to verify that the target
widget now does receive the event.

Second, I unintentionally stopped the event dispatcher from receiving pre
and post events. Fixed.
  • Loading branch information
jyrkive committed Jun 7, 2017
1 parent 315f849 commit 4c0f4c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/gui/core/event/dispatcher_private.hpp
Expand Up @@ -305,11 +305,15 @@ build_event_chain(const ui_event event, widget* dispatcher, widget* w)

std::vector<std::pair<widget*, ui_event>> result;

while(w != dispatcher) {
while(true) {
if(w->has_event(event, dispatcher::event_queue_type(dispatcher::pre | dispatcher::post))) {
result.emplace_back(w, event);
}

if(w == dispatcher) {
break;
}

w = w->parent();
assert(w);
}
Expand Down
13 changes: 7 additions & 6 deletions src/tests/gui/fire_event.cpp
Expand Up @@ -94,12 +94,13 @@ static void add_widget(gui2::grid& grid
static std::string set_event_order()
{
return
"pre:root\n"
"pre:level 1\n"
"child:level 2\n"
"post:level 1\n"
"post:root\n";

"pre:root\n"
"pre:level 1\n"
"pre:level 2\n"
"child:level 2\n"
"post:level 2\n"
"post:level 1\n"
"post:root\n";
}

/** @todo Add the rest of the events. */
Expand Down

0 comments on commit 4c0f4c3

Please sign in to comment.