diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index 7194d789..7273fb69 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -96,6 +96,7 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent) void EmuThread::attachWindow(MainWindow* window) { windowList.push_back(window); + window->attachEmuThread(this); mainWindow = windowList.front(); connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); @@ -128,6 +129,7 @@ void EmuThread::detachWindow(MainWindow* window) disconnect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled())); windowList.remove(window); + window->attachEmuThread(nullptr); mainWindow = windowList.front(); } diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index 25f39638..cb633313 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -85,7 +85,7 @@ using namespace melonDS; // TEMP extern MainWindow* mainWindow; -extern EmuThread* emuThread; +//extern EmuThread* emuThread; extern bool RunningSomething; extern QString NdsRomMimeType; extern QStringList NdsRomExtensions; @@ -685,6 +685,11 @@ MainWindow::~MainWindow() delete[] actScreenAspectBot; } +void MainWindow::attachEmuThread(EmuThread* thread) +{ + emuThread = thread; +} + void MainWindow::osdAddMessage(unsigned int color, const char* fmt, ...) { if (fmt == nullptr) diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index efddcf8f..9fb7cf1e 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -103,6 +103,8 @@ public: explicit MainWindow(QWidget* parent = nullptr); ~MainWindow(); + void attachEmuThread(EmuThread* thread); + bool hasOpenGL() { return hasOGL; } GL::Context* getOGLContext(); void initOpenGL(); @@ -234,6 +236,8 @@ private: int test_num; + EmuThread* emuThread; + public: ScreenPanel* panel;