Skip to content

Commit

Permalink
Clear the event queue between game executions (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
clementgallet committed May 15, 2020
1 parent 7270054 commit 81135d9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* Set current cell when removing a row in input editor so that array keys work (#329)
* Fix locale names (#267)
* Fix when savefile was removed and re-opened (#267)
* Clear the event queue between game executions (#325)

## [1.3.5] - 2019-11-26
### Added
Expand Down
12 changes: 9 additions & 3 deletions src/program/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,15 @@ void GameLoop::init()
else
context->gamename = context->gamepath;

/* Clear the event queue and parameters */
xcb_generic_event_t *event;
do {
event = xcb_poll_for_event(context->conn);
} while (event);

last_pressed_key = 0;
next_event = nullptr;

/* Remove savestates again in case we did not exist cleanly the previous time */
remove_savestates(context);

Expand Down Expand Up @@ -671,9 +680,6 @@ bool GameLoop::startFrameMessages()

uint8_t GameLoop::nextEvent(struct HotKey &hk)
{
static xcb_keycode_t last_pressed_key = 0;
static xcb_generic_event_t *next_event = nullptr;

while (true) {
xcb_generic_event_t *event;

Expand Down
3 changes: 3 additions & 0 deletions src/program/GameLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class GameLoop : public QObject {
int pointer_offset_x;
int pointer_offset_y;

xcb_keycode_t last_pressed_key;
xcb_generic_event_t *next_event;

void init();

void initProcessMessages();
Expand Down
3 changes: 3 additions & 0 deletions src/program/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,9 @@ void MainWindow::updateRecentGamepaths()

void MainWindow::updateUIFrequent()
{
if (context->status != Context::ACTIVE)
return;

/* Update frame count */
frameCount->setValue(context->framecount);
movieFrameCount->setValue(context->config.sc.movie_framecount);
Expand Down

0 comments on commit 81135d9

Please sign in to comment.