Skip to content

Commit

Permalink
Qt: Fix ClearBindStateFromSource() executing on wrong thread
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jul 24, 2023
1 parent af5f1c7 commit 72f7225
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/duckstation-qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void MainWindow::onApplicationStateChanged(Qt::ApplicationState state)
// Clear the state of all keyboard binds.
// That way, if we had a key held down, and lost focus, the bind won't be stuck enabled because we never
// got the key release message, because it happened in another window which "stole" the event.
InputManager::ClearBindStateFromSource(InputManager::MakeHostKeyboardKey(0));
g_emu_thread->clearInputBindStateFromSource(InputManager::MakeHostKeyboardKey(0));
}
else
{
Expand Down
11 changes: 11 additions & 0 deletions src/duckstation-qt/qthost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,17 @@ void EmuThread::reloadPostProcessingShaders()
System::ReloadPostProcessingShaders();
}

void EmuThread::clearInputBindStateFromSource(InputBindingKey key)
{
if (!isOnThread())
{
QMetaObject::invokeMethod(this, "clearInputBindStateFromSource", Qt::QueuedConnection, Q_ARG(InputBindingKey, key));
return;
}

InputManager::ClearBindStateFromSource(key);
}

void EmuThread::runOnEmuThread(std::function<void()> callback)
{
callback();
Expand Down
1 change: 1 addition & 0 deletions src/duckstation-qt/qthost.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public Q_SLOTS:
void setCheatEnabled(quint32 index, bool enabled);
void applyCheat(quint32 index);
void reloadPostProcessingShaders();
void clearInputBindStateFromSource(InputBindingKey key);

private Q_SLOTS:
void stopInThread();
Expand Down

0 comments on commit 72f7225

Please sign in to comment.