Qt: Add function to recreate the main window

This commit is contained in:
Connor McLaughlin
2021-08-16 14:06:16 +10:00
parent 971af2cb5c
commit 47f85dc453
4 changed files with 19 additions and 3 deletions

View File

@ -82,7 +82,8 @@ MainWindow::MainWindow(QtHostInterface* host_interface)
MainWindow::~MainWindow()
{
Assert(!m_display_widget);
m_host_interface->setMainWindow(nullptr);
if (m_host_interface->getMainWindow() == this)
m_host_interface->setMainWindow(nullptr);
Assert(!m_debugger_window);
}
@ -562,6 +563,19 @@ std::string MainWindow::getDeviceDiscPath(const QString& title)
return ret;
}
void MainWindow::recreate()
{
if (m_emulation_running)
m_host_interface->synchronousPowerOffSystem();
close();
m_host_interface->setMainWindow(nullptr);
MainWindow* new_main_window = new MainWindow(m_host_interface);
new_main_window->initializeAndShow();
deleteLater();
}
void MainWindow::onStartDiscActionTriggered()
{
std::string path(getDeviceDiscPath(tr("Start Disc")));