mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-27 00:00:07 -06:00
window: undo last commit (was a trainwreck). explicitly close child windows to avoid GL issues. fix bug with window parenting in second multiplayer instances.
This commit is contained in:
@ -204,7 +204,7 @@ void EmuInstance::createWindow(int id)
|
|||||||
if (windowList[id])
|
if (windowList[id])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MainWindow* win = new MainWindow(id, this, topWindow);
|
MainWindow* win = new MainWindow(id, this, mainWindow ? mainWindow : topWindow);
|
||||||
if (!topWindow) topWindow = win;
|
if (!topWindow) topWindow = win;
|
||||||
if (!mainWindow) mainWindow = win;
|
if (!mainWindow) mainWindow = win;
|
||||||
windowList[id] = win;
|
windowList[id] = win;
|
||||||
|
@ -809,18 +809,6 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
if (windowID == 0)
|
|
||||||
emuInstance->saveEnabledWindows();
|
|
||||||
else
|
|
||||||
saveEnabled(false);
|
|
||||||
|
|
||||||
QByteArray geom = saveGeometry();
|
|
||||||
QByteArray enc = geom.toBase64(QByteArray::Base64Encoding);
|
|
||||||
windowCfg.SetString("Geometry", enc.toStdString());
|
|
||||||
Config::Save();
|
|
||||||
|
|
||||||
emuInstance->deleteWindow(windowID, false);
|
|
||||||
|
|
||||||
if (hasMenu)
|
if (hasMenu)
|
||||||
{
|
{
|
||||||
delete[] actScreenAspectTop;
|
delete[] actScreenAspectTop;
|
||||||
@ -841,6 +829,36 @@ void MainWindow::saveEnabled(bool enabled)
|
|||||||
enabledSaved = true;
|
enabledSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
if (emuInstance)
|
||||||
|
{
|
||||||
|
if (windowID == 0)
|
||||||
|
emuInstance->saveEnabledWindows();
|
||||||
|
else
|
||||||
|
saveEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// explicitly close children windows, so the OpenGL contexts get closed properly
|
||||||
|
auto childwins = findChildren<MainWindow *>(nullptr, Qt::FindDirectChildrenOnly);
|
||||||
|
for (auto child : childwins)
|
||||||
|
child->close();
|
||||||
|
|
||||||
|
if (!emuInstance) return;
|
||||||
|
|
||||||
|
QByteArray geom = saveGeometry();
|
||||||
|
QByteArray enc = geom.toBase64(QByteArray::Base64Encoding);
|
||||||
|
windowCfg.SetString("Geometry", enc.toStdString());
|
||||||
|
Config::Save();
|
||||||
|
|
||||||
|
emuInstance->deleteWindow(windowID, false);
|
||||||
|
|
||||||
|
// emuInstance may be deleted
|
||||||
|
// prevent use after free from us
|
||||||
|
emuInstance = nullptr;
|
||||||
|
QMainWindow::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::createScreenPanel()
|
void MainWindow::createScreenPanel()
|
||||||
{
|
{
|
||||||
if (panel) delete panel;
|
if (panel) delete panel;
|
||||||
|
@ -242,6 +242,8 @@ private slots:
|
|||||||
void onScreenEmphasisToggled();
|
void onScreenEmphasisToggled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
QStringList currentROM;
|
QStringList currentROM;
|
||||||
QStringList currentGBAROM;
|
QStringList currentGBAROM;
|
||||||
QList<QString> recentFileList;
|
QList<QString> recentFileList;
|
||||||
|
Reference in New Issue
Block a user