mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 06:10:03 -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()
|
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;
|
||||||
@ -829,28 +841,6 @@ void MainWindow::saveEnabled(bool enabled)
|
|||||||
enabledSaved = true;
|
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()
|
void MainWindow::createScreenPanel()
|
||||||
{
|
{
|
||||||
if (panel) delete panel;
|
if (panel) delete panel;
|
||||||
|
@ -242,8 +242,6 @@ 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