lay down basic idea of multi-instance support

This commit is contained in:
Arisotura 2024-06-04 23:00:03 +02:00
parent 83c9b8dd42
commit 153f01ec54
5 changed files with 23 additions and 30 deletions

View File

@ -29,7 +29,7 @@
#include "main.h"
// REMOVE ME
extern EmuInstance* testinst;
//extern EmuInstance* testinst;
#ifdef __WIN32__
#include <iphlpapi.h>
@ -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++)
{

View File

@ -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)

View File

@ -237,8 +237,6 @@ private:
bool pauseOnLostFocus;
bool pausedManually;
int test_num;
int windowID;
EmuInstance* emuInstance;

View File

@ -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];

View File

@ -48,4 +48,8 @@ public:
extern QString* systemThemeName;
extern QString emuDirectory;
bool createEmuInstance();
void deleteEmuInstance(int id);
void deleteAllEmuInstances();
#endif // MAIN_H