diff --git a/src/frontend/qt_sdl/LAN_PCap.cpp b/src/frontend/qt_sdl/LAN_PCap.cpp index f95eef45..7fc1c2b6 100644 --- a/src/frontend/qt_sdl/LAN_PCap.cpp +++ b/src/frontend/qt_sdl/LAN_PCap.cpp @@ -29,7 +29,7 @@ #include "main.h" // REMOVE ME -extern EmuInstance* testinst; +//extern EmuInstance* testinst; #ifdef __WIN32__ #include @@ -322,7 +322,8 @@ bool Init(bool open_adapter) if (PCapAdapter) pcap_close(PCapAdapter); // open pcap device - std::string devicename = testinst->getGlobalConfig().GetString("LAN.Device"); + //std::string devicename = testinst->getGlobalConfig().GetString("LAN.Device"); + std::string devicename = "FIXME"; PCapAdapterData = &Adapters[0]; for (int i = 0; i < NumAdapters; i++) { diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index bda0df27..5fa61a1a 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -222,7 +222,6 @@ static void signalHandler(int) } #endif -int test = 0; MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : QMainWindow(parent), @@ -233,7 +232,6 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")), emuThread(inst->getEmuThread()) { - test_num = test++; #ifndef _WIN32 if (!parent) { @@ -749,16 +747,21 @@ void MainWindow::closeEvent(QCloseEvent* event) Config::Save(); - if (hasOGL) + if (hasOGL && (windowID == 0)) { // we intentionally don't unpause here - // TODO this ought to change if we do multi-window shiz emuThread->emuPause(); emuThread->deinitContext(); } emuThread->detachWindow(this); + if (windowID == 0) + { + int inst = emuInstance->instanceID; + deleteEmuInstance(inst); + } + QMainWindow::closeEvent(event); } @@ -1575,9 +1578,10 @@ void MainWindow::onImportSavefile() void MainWindow::onQuit() { #ifndef _WIN32 - signalSn->setEnabled(false); + if (!parentWidget()) + signalSn->setEnabled(false); #endif - QApplication::quit(); + close(); } @@ -1676,19 +1680,7 @@ void MainWindow::onOpenTitleManager() void MainWindow::onMPNewInstance() { - //QProcess::startDetached(QApplication::applicationFilePath()); - QProcess newinst; - newinst.setProgram(QApplication::applicationFilePath()); - newinst.setArguments(QApplication::arguments().mid(1, QApplication::arguments().length()-1)); - -#ifdef __WIN32__ - newinst.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) - { - args->flags |= CREATE_NEW_CONSOLE; - }); -#endif - - newinst.startDetached(); + createEmuInstance(); } void MainWindow::onOpenEmuSettings() @@ -2015,7 +2007,7 @@ void MainWindow::onChangeAudioSync(bool checked) void MainWindow::onTitleUpdate(QString title) { - setWindowTitle(test_num ? "SECOND WINDOW" : title); + setWindowTitle(title); } void ToggleFullscreen(MainWindow* mainWindow) diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 8209eb65..bcea1cca 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -237,8 +237,6 @@ private: bool pauseOnLostFocus; bool pausedManually; - int test_num; - int windowID; EmuInstance* emuInstance; diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 1843aa5a..8dd5cb43 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -85,10 +85,6 @@ QString* systemThemeName; QString emuDirectory; -//MainWindow* mainWindow; -//EmuThread* emuThread; -EmuInstance* testinst; - const int kMaxEmuInstances = 16; EmuInstance* emuInstances[kMaxEmuInstances]; @@ -282,7 +278,7 @@ int main(int argc, char** argv) emuThread->start(); emuThread->emuPause();*/ - testinst = new EmuInstance(0); + createEmuInstance(); /*AudioInOut::Init(emuThread); ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0); @@ -318,7 +314,9 @@ int main(int argc, char** argv) /*emuThread->emuStop(); emuThread->wait(); delete emuThread;*/ - delete testinst; + // if we get here, all the existing emu instances should have been deleted already + // but with this we make extra sure they are all deleted + deleteAllEmuInstances(); //AudioInOut::DeInit(); delete camManager[0]; diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index 00f190ea..77ee517e 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -48,4 +48,8 @@ public: extern QString* systemThemeName; extern QString emuDirectory; +bool createEmuInstance(); +void deleteEmuInstance(int id); +void deleteAllEmuInstances(); + #endif // MAIN_H