mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-22 05:40:15 -06:00
window: move cleanup code to destructor (closeEvent() isn't called for children)
This commit is contained in:
@ -809,6 +809,18 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||
|
||||
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)
|
||||
{
|
||||
delete[] actScreenAspectTop;
|
||||
@ -829,28 +841,6 @@ void MainWindow::saveEnabled(bool enabled)
|
||||
enabledSaved = true;
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (!emuInstance) return;
|
||||
|
||||
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);
|
||||
|
||||
// emuInstance may be deleted
|
||||
// prevent use after free from us
|
||||
emuInstance = nullptr;
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::createScreenPanel()
|
||||
{
|
||||
if (panel) delete panel;
|
||||
|
@ -242,8 +242,6 @@ private slots:
|
||||
void onScreenEmphasisToggled();
|
||||
|
||||
private:
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
QStringList currentROM;
|
||||
QStringList currentGBAROM;
|
||||
QList<QString> recentFileList;
|
||||
|
Reference in New Issue
Block a user