From 762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 16 Apr 2015 18:35:09 -0400 Subject: Qt: Move EmuThread ownership from render window to main window. --- src/citra_qt/bootmanager.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/citra_qt/bootmanager.h') diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 288da45a1..d3eab6ec1 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -14,6 +14,7 @@ class QScreen; class QKeyEvent; class GRenderWindow; +class GMainWindow; class EmuThread : public QThread { @@ -67,7 +68,7 @@ public slots: void Stop(); private: - friend class GRenderWindow; + friend class GMainWindow; EmuThread(GRenderWindow* render_window); @@ -100,10 +101,7 @@ class GRenderWindow : public QWidget, public EmuWindow Q_OBJECT public: - GRenderWindow(QWidget* parent = NULL); - ~GRenderWindow(); - - void closeEvent(QCloseEvent*) override; + GRenderWindow(QWidget* parent, GMainWindow& main_window); // EmuWindow implementation void SwapBuffers() override; @@ -116,8 +114,6 @@ public: void restoreGeometry(const QByteArray& geometry); // overridden QByteArray saveGeometry(); // overridden - EmuThread& GetEmuThread(); - void keyPressEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override; @@ -139,10 +135,10 @@ private: QGLWidget* child; - EmuThread emu_thread; - QByteArray geometry; + GMainWindow& main_window; + /// Device id of keyboard for use with KeyMap int keyboard_id; }; -- cgit v1.2.3 From d5665fea89dc2684e145e82a1b07086f11a13a65 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 16 Apr 2015 19:19:05 -0400 Subject: EmuThread: Remove unused filename attribute. --- src/citra_qt/bootmanager.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/citra_qt/bootmanager.h') diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index d3eab6ec1..8083d275b 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -21,13 +21,6 @@ class EmuThread : public QThread Q_OBJECT public: - /** - * Set image filename - * - * @param filename - * @warning Only call when not running! - */ - void SetFilename(std::string filename); /** * Start emulation (on new thread) @@ -72,8 +65,6 @@ private: EmuThread(GRenderWindow* render_window); - std::string filename; - bool exec_cpu_step; bool cpu_running; std::atomic stop_run; -- cgit v1.2.3 From 28df8dbfeb17cf5a002a5504a6bd2ba5091bf07c Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 16 Apr 2015 23:31:14 -0400 Subject: Qt: Create emu thread on bootup, kill it on shutdown. --- src/citra_qt/bootmanager.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/citra_qt/bootmanager.h') diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 8083d275b..f6f09773c 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -9,6 +9,7 @@ #include "common/common.h" #include "common/emu_window.h" +#include "common/thread.h" class QScreen; class QKeyEvent; @@ -37,20 +38,31 @@ public: void ExecStep() { exec_cpu_step = true; } /** - * Allow the CPU to continue processing instructions without interruption + * Sets whether the CPU is running * * @note This function is thread-safe */ void SetCpuRunning(bool running) { cpu_running = running; } /** - * Allow the CPU to continue processing instructions without interruption - * - * @note This function is thread-safe - */ + * Allow the CPU to continue processing instructions without interruption + * + * @note This function is thread-safe + */ bool IsCpuRunning() { return cpu_running; } + /** + * Shutdown (permantently stops) the CPU + */ + void ShutdownCpu() { stop_run = true; }; + + /** + * Waits for the CPU shutdown to complete + */ + void WaitForCpuShutdown() { shutdown_event.Wait(); } + + public slots: /** * Stop emulation and wait for the thread to finish. @@ -71,6 +83,8 @@ private: GRenderWindow* render_window; + Common::Event shutdown_event; + signals: /** * Emitted when the CPU has halted execution -- cgit v1.2.3 From e4ea133717a5292339c134160da984ba186d3de8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 28 Apr 2015 19:03:01 -0400 Subject: Qt: Restructured to remove unnecessary shutdown event and various cleanups. --- src/citra_qt/bootmanager.h | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'src/citra_qt/bootmanager.h') diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index f6f09773c..e9b3ea664 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -25,66 +25,46 @@ public: /** * Start emulation (on new thread) - * * @warning Only call when not running! */ void run() override; /** - * Allow the CPU to process a single instruction (if cpu is not running) - * + * Steps the emulation thread by a single CPU instruction (if the CPU is not already running) * @note This function is thread-safe */ - void ExecStep() { exec_cpu_step = true; } + void ExecStep() { exec_step = true; } /** - * Sets whether the CPU is running - * + * Sets whether the emulation thread is running or not + * @param running Boolean value, set the emulation thread to running if true * @note This function is thread-safe */ - void SetCpuRunning(bool running) { cpu_running = running; } + void SetRunning(bool running) { this->running = running; } /** - * Allow the CPU to continue processing instructions without interruption - * + * Check if the emulation thread is running or not + * @return True if the emulation thread is running, otherwise false * @note This function is thread-safe */ - bool IsCpuRunning() { return cpu_running; } - - - /** - * Shutdown (permantently stops) the CPU - */ - void ShutdownCpu() { stop_run = true; }; + bool IsRunning() { return running; } /** - * Waits for the CPU shutdown to complete + * Shutdown (permanently stops) the emulation thread */ - void WaitForCpuShutdown() { shutdown_event.Wait(); } - - -public slots: - /** - * Stop emulation and wait for the thread to finish. - * - * @details: This function will wait a second for the thread to finish; if it hasn't finished until then, we'll terminate() it and wait another second, hoping that it will be terminated by then. - * @note: This function is thread-safe. - */ - void Stop(); + void Shutdown() { stop_run = true; }; private: friend class GMainWindow; EmuThread(GRenderWindow* render_window); - bool exec_cpu_step; - bool cpu_running; + bool exec_step; + bool running; std::atomic stop_run; GRenderWindow* render_window; - Common::Event shutdown_event; - signals: /** * Emitted when the CPU has halted execution -- cgit v1.2.3 From 43cf42490730d8a1b980aa1fe9ebbbe1249232ef Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 29 Apr 2015 00:01:41 -0400 Subject: Qt: Use signals for emu_thread start/stop and fix disasm widget. --- src/citra_qt/bootmanager.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/citra_qt/bootmanager.h') diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index e9b3ea664..e57522187 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -22,6 +22,7 @@ class EmuThread : public QThread Q_OBJECT public: + EmuThread(GRenderWindow* render_window); /** * Start emulation (on new thread) @@ -50,15 +51,14 @@ public: bool IsRunning() { return running; } /** - * Shutdown (permanently stops) the emulation thread + * Requests for the emulation thread to stop running and shutdown emulation */ - void Shutdown() { stop_run = true; }; + void RequestShutdown() { + stop_run = true; + running = false; + }; private: - friend class GMainWindow; - - EmuThread(GRenderWindow* render_window); - bool exec_step; bool running; std::atomic stop_run; @@ -86,7 +86,7 @@ class GRenderWindow : public QWidget, public EmuWindow Q_OBJECT public: - GRenderWindow(QWidget* parent, GMainWindow& main_window); + GRenderWindow(QWidget* parent, EmuThread* emu_thread); // EmuWindow implementation void SwapBuffers() override; @@ -115,6 +115,9 @@ public: public slots: void moveContext(); // overridden + void OnEmulationStarted(EmuThread* emu_thread); + void OnEmulationStopped(); + private: void OnMinimalClientAreaChangeRequest(const std::pair& minimal_size) override; @@ -122,8 +125,8 @@ private: QByteArray geometry; - GMainWindow& main_window; - /// Device id of keyboard for use with KeyMap int keyboard_id; + + EmuThread* emu_thread; }; -- cgit v1.2.3 From bc41de2131728192e3fd4c8c83e8b2d6e5ba4530 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 30 Apr 2015 19:46:50 -0400 Subject: Qt: Fixed a bug in shutdown procedure, various cleanups. --- src/citra_qt/bootmanager.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/citra_qt/bootmanager.h') diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index e57522187..715faf2d7 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -51,9 +51,9 @@ public: bool IsRunning() { return running; } /** - * Requests for the emulation thread to stop running and shutdown emulation + * Requests for the emulation thread to stop running */ - void RequestShutdown() { + void RequestStop() { stop_run = true; running = false; }; @@ -115,8 +115,8 @@ public: public slots: void moveContext(); // overridden - void OnEmulationStarted(EmuThread* emu_thread); - void OnEmulationStopped(); + void OnEmulationStarting(EmuThread* emu_thread); + void OnEmulationStopping(); private: void OnMinimalClientAreaChangeRequest(const std::pair& minimal_size) override; -- cgit v1.2.3