mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-27 08:05:41 +00:00
Pass a SystemBootParameters pointer to QtHostInterface::bootSystem
This resolves ownership issues related to the SystemBootParameters class, since it's meant to be non-copyable but it was copied as per Qt meta type rules
This commit is contained in:
parent
95d5417017
commit
c47dceffb5
|
@ -28,7 +28,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
std::unique_ptr<QtHostInterface> host_interface = std::make_unique<QtHostInterface>();
|
||||
std::unique_ptr<SystemBootParameters> 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
|
||||
{
|
||||
|
|
|
@ -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<const SystemBootParameters>(filename.toStdString()));
|
||||
}
|
||||
|
||||
void MainWindow::onStartBIOSActionTriggered()
|
||||
{
|
||||
SystemBootParameters boot_params;
|
||||
m_host_interface->bootSystem(boot_params);
|
||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>());
|
||||
}
|
||||
|
||||
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<const SystemBootParameters>(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<const SystemBootParameters>(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<SystemBootParameters>(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<SystemBootParameters>(entry->path);
|
||||
boot_params->override_fast_boot = false;
|
||||
m_host_interface->bootSystem(std::move(boot_params));
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
|
@ -44,7 +44,7 @@ Log_SetChannel(QtHostInterface);
|
|||
|
||||
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
|
||||
{
|
||||
qRegisterMetaType<SystemBootParameters>();
|
||||
qRegisterMetaType<std::shared_ptr<const SystemBootParameters>>();
|
||||
}
|
||||
|
||||
QtHostInterface::~QtHostInterface()
|
||||
|
@ -171,12 +171,6 @@ bool QtHostInterface::ConfirmMessage(const char* message)
|
|||
return result;
|
||||
}
|
||||
|
||||
bool QtHostInterface::parseCommandLineParameters(int argc, char* argv[],
|
||||
std::unique_ptr<SystemBootParameters>* 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<const SystemBootParameters> 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<const SystemBootParameters>, std::move(params)));
|
||||
return;
|
||||
}
|
||||
|
||||
emit emulationStarting();
|
||||
BootSystem(params);
|
||||
BootSystem(*params);
|
||||
}
|
||||
|
||||
void QtHostInterface::resumeSystemFromState(const QString& filename, bool boot_on_failure)
|
||||
|
|
|
@ -30,7 +30,7 @@ class INISettingsInterface;
|
|||
class MainWindow;
|
||||
class QtDisplayWidget;
|
||||
|
||||
Q_DECLARE_METATYPE(SystemBootParameters);
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<const SystemBootParameters>);
|
||||
|
||||
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<SystemBootParameters>* 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<const SystemBootParameters> params);
|
||||
void resumeSystemFromState(const QString& filename, bool boot_on_failure);
|
||||
void resumeSystemFromMostRecentState();
|
||||
void powerOffSystem();
|
||||
|
|
Loading…
Reference in a new issue