Don't pump events in SdlGamepadKeyNavigation
This can cause reentrancy issues by invoking Qt-based event processing while in the context of SDL (via libdecor's GTK loop). Fixes #1802
This commit is contained in:
parent
e4be57db5d
commit
d5b7ef0c58
1 changed files with 10 additions and 4 deletions
|
|
@ -51,7 +51,11 @@ void SdlGamepadKeyNavigation::enable()
|
||||||
// on first init of the GC subsystem. We can't depend on them due to
|
// on first init of the GC subsystem. We can't depend on them due to
|
||||||
// overlapping lifetimes of SdlGamepadKeyNavigation instances, so we
|
// overlapping lifetimes of SdlGamepadKeyNavigation instances, so we
|
||||||
// will attach ourselves.
|
// will attach ourselves.
|
||||||
SDL_PumpEvents();
|
//
|
||||||
|
// NB: We use SDL_JoystickUpdate() instead of SDL_PumpEvents() because
|
||||||
|
// the latter can do a bit more work that we want (like handling video
|
||||||
|
// events that we intentionally do not want to process yet).
|
||||||
|
SDL_JoystickUpdate();
|
||||||
SDL_FlushEvent(SDL_CONTROLLERDEVICEADDED);
|
SDL_FlushEvent(SDL_CONTROLLERDEVICEADDED);
|
||||||
|
|
||||||
// Open all currently attached game controllers
|
// Open all currently attached game controllers
|
||||||
|
|
@ -99,17 +103,19 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
|
// Update joystick state without pumping other events (see enable() comment)
|
||||||
|
SDL_JoystickUpdate();
|
||||||
|
|
||||||
// Discard any pending button events on the first poll to avoid picking up
|
// Discard any pending button events on the first poll to avoid picking up
|
||||||
// stale input data from the stream session (like the quit combo).
|
// stale input data from the stream session (like the quit combo).
|
||||||
if (m_FirstPoll) {
|
if (m_FirstPoll) {
|
||||||
SDL_PumpEvents();
|
|
||||||
SDL_FlushEvent(SDL_CONTROLLERBUTTONDOWN);
|
SDL_FlushEvent(SDL_CONTROLLERBUTTONDOWN);
|
||||||
SDL_FlushEvent(SDL_CONTROLLERBUTTONUP);
|
SDL_FlushEvent(SDL_CONTROLLERBUTTONUP);
|
||||||
|
|
||||||
m_FirstPoll = false;
|
m_FirstPoll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (SDL_PollEvent(&event)) {
|
// Peep events rather than polling to avoid calling SDL_PumpEvents()
|
||||||
|
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
// SDL may send us a quit event since we initialize
|
// SDL may send us a quit event since we initialize
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue