diff options
| author | 2015-04-16 18:35:09 -0400 | |
|---|---|---|
| committer | 2015-05-01 18:26:58 -0400 | |
| commit | 762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf (patch) | |
| tree | 74ac7be2a6f1b3dfd09986b598844440af9e2f8f /src/citra_qt/bootmanager.cpp | |
| parent | Merge pull request #717 from linkmauve/useless-auto (diff) | |
| download | yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.gz yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.xz yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.zip | |
Qt: Move EmuThread ownership from render window to main window.
Diffstat (limited to 'src/citra_qt/bootmanager.cpp')
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index b81bd6167..50c8fed1e 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "common/common.h" | 11 | #include "common/common.h" |
| 12 | #include "bootmanager.h" | 12 | #include "bootmanager.h" |
| 13 | #include "main.h" | ||
| 13 | 14 | ||
| 14 | #include "core/core.h" | 15 | #include "core/core.h" |
| 15 | #include "core/settings.h" | 16 | #include "core/settings.h" |
| @@ -30,6 +31,7 @@ EmuThread::EmuThread(GRenderWindow* render_window) : | |||
| 30 | filename(""), exec_cpu_step(false), cpu_running(false), | 31 | filename(""), exec_cpu_step(false), cpu_running(false), |
| 31 | stop_run(false), render_window(render_window) | 32 | stop_run(false), render_window(render_window) |
| 32 | { | 33 | { |
| 34 | connect(this, SIGNAL(started()), render_window, SLOT(moveContext())); | ||
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | void EmuThread::SetFilename(std::string filename) | 37 | void EmuThread::SetFilename(std::string filename) |
| @@ -133,13 +135,9 @@ private: | |||
| 133 | GRenderWindow* parent; | 135 | GRenderWindow* parent; |
| 134 | }; | 136 | }; |
| 135 | 137 | ||
| 136 | EmuThread& GRenderWindow::GetEmuThread() | 138 | GRenderWindow::GRenderWindow(QWidget* parent, GMainWindow& main_window) : |
| 137 | { | 139 | QWidget(parent), main_window(main_window), keyboard_id(0) { |
| 138 | return emu_thread; | ||
| 139 | } | ||
| 140 | 140 | ||
| 141 | GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this), keyboard_id(0) | ||
| 142 | { | ||
| 143 | std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); | 141 | std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); |
| 144 | setWindowTitle(QString::fromStdString(window_title)); | 142 | setWindowTitle(QString::fromStdString(window_title)); |
| 145 | 143 | ||
| @@ -160,7 +158,6 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this | |||
| 160 | layout->addWidget(child); | 158 | layout->addWidget(child); |
| 161 | layout->setMargin(0); | 159 | layout->setMargin(0); |
| 162 | setLayout(layout); | 160 | setLayout(layout); |
| 163 | connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); | ||
| 164 | 161 | ||
| 165 | OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); | 162 | OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); |
| 166 | 163 | ||
| @@ -180,29 +177,17 @@ void GRenderWindow::moveContext() | |||
| 180 | // We need to move GL context to the swapping thread in Qt5 | 177 | // We need to move GL context to the swapping thread in Qt5 |
| 181 | #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) | 178 | #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) |
| 182 | // If the thread started running, move the GL Context to the new thread. Otherwise, move it back. | 179 | // If the thread started running, move the GL Context to the new thread. Otherwise, move it back. |
| 183 | child->context()->moveToThread((QThread::currentThread() == qApp->thread()) ? &emu_thread : qApp->thread()); | 180 | auto thread = QThread::currentThread() == qApp->thread() ? main_window.GetEmuThread() : qApp->thread(); |
| 181 | child->context()->moveToThread(thread); | ||
| 184 | #endif | 182 | #endif |
| 185 | } | 183 | } |
| 186 | 184 | ||
| 187 | GRenderWindow::~GRenderWindow() | ||
| 188 | { | ||
| 189 | if (emu_thread.isRunning()) | ||
| 190 | emu_thread.Stop(); | ||
| 191 | } | ||
| 192 | |||
| 193 | void GRenderWindow::SwapBuffers() | 185 | void GRenderWindow::SwapBuffers() |
| 194 | { | 186 | { |
| 195 | // MakeCurrent is already called in renderer_opengl | 187 | // MakeCurrent is already called in renderer_opengl |
| 196 | child->swapBuffers(); | 188 | child->swapBuffers(); |
| 197 | } | 189 | } |
| 198 | 190 | ||
| 199 | void GRenderWindow::closeEvent(QCloseEvent* event) | ||
| 200 | { | ||
| 201 | if (emu_thread.isRunning()) | ||
| 202 | emu_thread.Stop(); | ||
| 203 | QWidget::closeEvent(event); | ||
| 204 | } | ||
| 205 | |||
| 206 | void GRenderWindow::MakeCurrent() | 191 | void GRenderWindow::MakeCurrent() |
| 207 | { | 192 | { |
| 208 | child->makeCurrent(); | 193 | child->makeCurrent(); |