diff --git a/src/duckstation-qt/main.cpp b/src/duckstation-qt/main.cpp index c30fc6a52..66bf4bf51 100644 --- a/src/duckstation-qt/main.cpp +++ b/src/duckstation-qt/main.cpp @@ -28,7 +28,7 @@ int main(int argc, char* argv[]) std::unique_ptr host_interface = std::make_unique(); std::unique_ptr boot_params; - if (!host_interface->parseCommandLineParameters(argc, argv, &boot_params)) + if (!host_interface->ParseCommandLineParameters(argc, argv, &boot_params)) return EXIT_FAILURE; if (!host_interface->Initialize()) @@ -48,8 +48,7 @@ int main(int argc, char* argv[]) if (boot_params) { - host_interface->bootSystem(*boot_params); - boot_params.reset(); + host_interface->bootSystem(std::move(boot_params)); } else { diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 3e62e9bca..dc07087c4 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -269,15 +269,12 @@ void MainWindow::onStartDiscActionTriggered() if (filename.isEmpty()) return; - SystemBootParameters boot_params; - boot_params.filename = filename.toStdString(); - m_host_interface->bootSystem(boot_params); + m_host_interface->bootSystem(std::make_shared(filename.toStdString())); } void MainWindow::onStartBIOSActionTriggered() { - SystemBootParameters boot_params; - m_host_interface->bootSystem(boot_params); + m_host_interface->bootSystem(std::make_shared()); } void MainWindow::onChangeDiscFromFileActionTriggered() @@ -391,9 +388,7 @@ void MainWindow::onGameListEntryDoubleClicked(const GameListEntry* entry) } else { - SystemBootParameters boot_params; - boot_params.filename = path.toStdString(); - m_host_interface->bootSystem(boot_params); + m_host_interface->bootSystem(std::make_shared(path.toStdString())); } } else @@ -429,19 +424,20 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL menu.addSeparator(); } - connect(menu.addAction(tr("Default Boot")), &QAction::triggered, - [this, entry]() { m_host_interface->bootSystem(SystemBootParameters(entry->path)); }); + connect(menu.addAction(tr("Default Boot")), &QAction::triggered, [this, entry]() { + m_host_interface->bootSystem(std::make_shared(entry->path)); + }); connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() { - SystemBootParameters boot_params(entry->path); - boot_params.override_fast_boot = true; - m_host_interface->bootSystem(boot_params); + auto boot_params = std::make_shared(entry->path); + boot_params->override_fast_boot = true; + m_host_interface->bootSystem(std::move(boot_params)); }); connect(menu.addAction(tr("Full Boot")), &QAction::triggered, [this, entry]() { - SystemBootParameters boot_params(entry->path); - boot_params.override_fast_boot = false; - m_host_interface->bootSystem(boot_params); + auto boot_params = std::make_shared(entry->path); + boot_params->override_fast_boot = false; + m_host_interface->bootSystem(std::move(boot_params)); }); } else diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index d2a15eb18..831cc1b54 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -44,7 +44,7 @@ Log_SetChannel(QtHostInterface); QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface() { - qRegisterMetaType(); + qRegisterMetaType>(); } QtHostInterface::~QtHostInterface() @@ -171,12 +171,6 @@ bool QtHostInterface::ConfirmMessage(const char* message) return result; } -bool QtHostInterface::parseCommandLineParameters(int argc, char* argv[], - std::unique_ptr* out_boot_params) -{ - return CommonHostInterface::ParseCommandLineParameters(argc, argv, out_boot_params); -} - std::string QtHostInterface::GetStringSettingValue(const char* section, const char* key, const char* default_value /*= ""*/) { @@ -344,16 +338,17 @@ void QtHostInterface::setMainWindow(MainWindow* window) m_main_window = window; } -void QtHostInterface::bootSystem(const SystemBootParameters& params) +void QtHostInterface::bootSystem(std::shared_ptr params) { if (!isOnWorkerThread()) { - QMetaObject::invokeMethod(this, "bootSystem", Qt::QueuedConnection, Q_ARG(const SystemBootParameters&, params)); + QMetaObject::invokeMethod(this, "bootSystem", Qt::QueuedConnection, + Q_ARG(std::shared_ptr, std::move(params))); return; } emit emulationStarting(); - BootSystem(params); + BootSystem(*params); } void QtHostInterface::resumeSystemFromState(const QString& filename, bool boot_on_failure) diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 0d5c48721..d0616cd19 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -30,7 +30,7 @@ class INISettingsInterface; class MainWindow; class QtDisplayWidget; -Q_DECLARE_METATYPE(SystemBootParameters); +Q_DECLARE_METATYPE(std::shared_ptr); class QtHostInterface final : public QObject, public CommonHostInterface { @@ -49,8 +49,6 @@ public: void ReportMessage(const char* message) override; bool ConfirmMessage(const char* message) override; - bool parseCommandLineParameters(int argc, char* argv[], std::unique_ptr* out_boot_params); - /// Thread-safe settings access. std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override; bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false) override; @@ -141,7 +139,7 @@ public Q_SLOTS: void onDisplayWindowKeyEvent(int key, bool pressed); void onDisplayWindowMouseMoveEvent(int x, int y); void onDisplayWindowMouseButtonEvent(int button, bool pressed); - void bootSystem(const SystemBootParameters& params); + void bootSystem(std::shared_ptr params); void resumeSystemFromState(const QString& filename, bool boot_on_failure); void resumeSystemFromMostRecentState(); void powerOffSystem();