remove global emuThread from Window.cpp

This commit is contained in:
Arisotura 2024-02-20 13:29:21 +01:00
parent a7a7ac53c1
commit 6a2039aee1
3 changed files with 12 additions and 1 deletions

View File

@ -96,6 +96,7 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent)
void EmuThread::attachWindow(MainWindow* window) void EmuThread::attachWindow(MainWindow* window)
{ {
windowList.push_back(window); windowList.push_back(window);
window->attachEmuThread(this);
mainWindow = windowList.front(); mainWindow = windowList.front();
connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint()));
@ -128,6 +129,7 @@ void EmuThread::detachWindow(MainWindow* window)
disconnect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled())); disconnect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
windowList.remove(window); windowList.remove(window);
window->attachEmuThread(nullptr);
mainWindow = windowList.front(); mainWindow = windowList.front();
} }

View File

@ -85,7 +85,7 @@ using namespace melonDS;
// TEMP // TEMP
extern MainWindow* mainWindow; extern MainWindow* mainWindow;
extern EmuThread* emuThread; //extern EmuThread* emuThread;
extern bool RunningSomething; extern bool RunningSomething;
extern QString NdsRomMimeType; extern QString NdsRomMimeType;
extern QStringList NdsRomExtensions; extern QStringList NdsRomExtensions;
@ -685,6 +685,11 @@ MainWindow::~MainWindow()
delete[] actScreenAspectBot; delete[] actScreenAspectBot;
} }
void MainWindow::attachEmuThread(EmuThread* thread)
{
emuThread = thread;
}
void MainWindow::osdAddMessage(unsigned int color, const char* fmt, ...) void MainWindow::osdAddMessage(unsigned int color, const char* fmt, ...)
{ {
if (fmt == nullptr) if (fmt == nullptr)

View File

@ -103,6 +103,8 @@ public:
explicit MainWindow(QWidget* parent = nullptr); explicit MainWindow(QWidget* parent = nullptr);
~MainWindow(); ~MainWindow();
void attachEmuThread(EmuThread* thread);
bool hasOpenGL() { return hasOGL; } bool hasOpenGL() { return hasOGL; }
GL::Context* getOGLContext(); GL::Context* getOGLContext();
void initOpenGL(); void initOpenGL();
@ -234,6 +236,8 @@ private:
int test_num; int test_num;
EmuThread* emuThread;
public: public:
ScreenPanel* panel; ScreenPanel* panel;