mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
Qt: Add function to recreate the main window
This commit is contained in:
parent
971af2cb5c
commit
47f85dc453
|
@ -84,7 +84,7 @@ int main(int argc, char* argv[])
|
|||
if (!ParseCommandLineParameters(app, host_interface.get(), &boot_params))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
std::unique_ptr<MainWindow> window = std::make_unique<MainWindow>(host_interface.get());
|
||||
MainWindow* window = new MainWindow(host_interface.get());
|
||||
|
||||
if (!host_interface->Initialize())
|
||||
{
|
||||
|
@ -112,7 +112,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
int result = app.exec();
|
||||
|
||||
window.reset();
|
||||
host_interface->Shutdown();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -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")));
|
||||
|
|
|
@ -150,6 +150,7 @@ private:
|
|||
void updateMenuSelectedTheme();
|
||||
void ensureGameListLoaded();
|
||||
std::string getDeviceDiscPath(const QString& title);
|
||||
void recreate();
|
||||
|
||||
Ui::MainWindow m_ui;
|
||||
|
||||
|
|
|
@ -99,6 +99,8 @@ bool QtHostInterface::Initialize()
|
|||
void QtHostInterface::Shutdown()
|
||||
{
|
||||
stopThread();
|
||||
|
||||
delete m_main_window;
|
||||
}
|
||||
|
||||
bool QtHostInterface::initializeOnThread()
|
||||
|
|
Loading…
Reference in a new issue