Qt: Fix loading game when game is loaded

This commit is contained in:
Vicki Pfau 2018-06-25 10:24:10 -07:00
parent a19928f030
commit 0ae51f47d9
1 changed files with 9 additions and 6 deletions

View File

@ -737,6 +737,7 @@ void Window::gameStarted() {
} }
void Window::gameStopped() { void Window::gameStopped() {
m_controller.reset();
#ifdef M_CORE_GBA #ifdef M_CORE_GBA
for (QAction* action : m_gbaActions) { for (QAction* action : m_gbaActions) {
action->setDisabled(false); action->setDisabled(false);
@ -1807,17 +1808,19 @@ void Window::setController(CoreController* controller, const QString& fname) {
if (!controller) { if (!controller) {
return; return;
} }
if (m_controller) {
m_controller->stop();
QTimer::singleShot(0, this, [this, controller, fname]() {
setController(controller, fname);
});
return;
}
if (!fname.isEmpty()) { if (!fname.isEmpty()) {
setWindowFilePath(fname); setWindowFilePath(fname);
appendMRU(fname); appendMRU(fname);
} }
if (m_controller) {
m_controller->disconnect(this);
m_controller->stop();
m_controller.reset();
}
m_controller = std::shared_ptr<CoreController>(controller); m_controller = std::shared_ptr<CoreController>(controller);
m_inputController.recalibrateAxes(); m_inputController.recalibrateAxes();
m_controller->setInputController(&m_inputController); m_controller->setInputController(&m_inputController);