mirror of
https://github.com/PabloMK7/citra.git
synced 2024-12-02 04:09:37 +00:00
Stop emulation when render window is closed
This commit is contained in:
parent
f5a49df679
commit
86e29ac281
3 changed files with 15 additions and 0 deletions
|
@ -223,6 +223,11 @@ QByteArray GRenderWindow::saveGeometry()
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GRenderWindow::closeEvent(QCloseEvent* event) {
|
||||||
|
emit Closed();
|
||||||
|
QWidget::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void GRenderWindow::keyPressEvent(QKeyEvent* event)
|
void GRenderWindow::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
this->KeyPressed({event->key(), keyboard_id});
|
this->KeyPressed({event->key(), keyboard_id});
|
||||||
|
|
|
@ -110,6 +110,8 @@ public:
|
||||||
void restoreGeometry(const QByteArray& geometry); // overridden
|
void restoreGeometry(const QByteArray& geometry); // overridden
|
||||||
QByteArray saveGeometry(); // overridden
|
QByteArray saveGeometry(); // overridden
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
void keyReleaseEvent(QKeyEvent* event) override;
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
@ -129,6 +131,10 @@ public slots:
|
||||||
void OnEmulationStarting(EmuThread* emu_thread);
|
void OnEmulationStarting(EmuThread* emu_thread);
|
||||||
void OnEmulationStopping();
|
void OnEmulationStopping();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/// Emitted when the window is closed
|
||||||
|
void Closed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@ void GMainWindow::BootGame(const std::string& filename) {
|
||||||
render_window->moveContext();
|
render_window->moveContext();
|
||||||
emu_thread->start();
|
emu_thread->start();
|
||||||
|
|
||||||
|
connect(render_window, SIGNAL(Closed()), this, SLOT(OnStopGame()));
|
||||||
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views before the CPU continues
|
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views before the CPU continues
|
||||||
connect(emu_thread.get(), SIGNAL(DebugModeEntered()), disasmWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
|
connect(emu_thread.get(), SIGNAL(DebugModeEntered()), disasmWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
|
||||||
connect(emu_thread.get(), SIGNAL(DebugModeEntered()), registersWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
|
connect(emu_thread.get(), SIGNAL(DebugModeEntered()), registersWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
|
||||||
|
@ -283,6 +284,9 @@ void GMainWindow::ShutdownGame() {
|
||||||
emu_thread->wait();
|
emu_thread->wait();
|
||||||
emu_thread = nullptr;
|
emu_thread = nullptr;
|
||||||
|
|
||||||
|
// The emulation is stopped, so closing the window or not does not matter anymore
|
||||||
|
disconnect(render_window, SIGNAL(Closed()), this, SLOT(OnStopGame()));
|
||||||
|
|
||||||
// Update the GUI
|
// Update the GUI
|
||||||
ui.action_Start->setEnabled(false);
|
ui.action_Start->setEnabled(false);
|
||||||
ui.action_Start->setText(tr("Start"));
|
ui.action_Start->setText(tr("Start"));
|
||||||
|
|
Loading…
Reference in a new issue