Refactor SystemBootParameters ownership

This commit is contained in:
Silent
2021-06-08 18:38:12 +02:00
parent 4e282cd172
commit e21f2644d0
9 changed files with 32 additions and 41 deletions

View File

@ -478,12 +478,12 @@ void MainWindow::onStartDiscActionTriggered()
if (filename.isEmpty())
return;
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(filename.toStdString()));
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(filename.toStdString()));
}
void MainWindow::onStartBIOSActionTriggered()
{
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>());
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>());
}
void MainWindow::onChangeDiscFromFileActionTriggered()
@ -655,9 +655,8 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL
m_host_interface->populateGameListContextMenu(entry, this, &menu);
menu.addSeparator();
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("Default Boot")), &QAction::triggered,
[this, entry]() { m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(entry->path)); });
connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() {
auto boot_params = std::make_shared<SystemBootParameters>(entry->path);
@ -976,7 +975,7 @@ void MainWindow::startGameOrChangeDiscs(const std::string& path)
if (m_host_interface->CanResumeSystemFromFile(path.c_str()))
m_host_interface->resumeSystemFromState(QString::fromStdString(path), true);
else
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(path));
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(path));
}
else
{

View File

@ -52,7 +52,7 @@ Log_SetChannel(QtHostInterface);
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
{
qRegisterMetaType<std::shared_ptr<const SystemBootParameters>>();
qRegisterMetaType<std::shared_ptr<SystemBootParameters>>();
qRegisterMetaType<const GameListEntry*>();
qRegisterMetaType<GPURenderer>();
}
@ -333,17 +333,17 @@ void QtHostInterface::setMainWindow(MainWindow* window)
m_main_window = window;
}
void QtHostInterface::bootSystem(std::shared_ptr<const SystemBootParameters> params)
void QtHostInterface::bootSystem(std::shared_ptr<SystemBootParameters> params)
{
if (!isOnWorkerThread())
{
QMetaObject::invokeMethod(this, "bootSystem", Qt::QueuedConnection,
Q_ARG(std::shared_ptr<const SystemBootParameters>, std::move(params)));
Q_ARG(std::shared_ptr<SystemBootParameters>, std::move(params)));
return;
}
emit emulationStarting();
if (!BootSystem(*params))
if (!BootSystem(std::move(params)))
return;
// force a frame to be drawn to repaint the window

View File

@ -32,7 +32,7 @@ class INISettingsInterface;
class MainWindow;
class QtDisplayWidget;
Q_DECLARE_METATYPE(std::shared_ptr<const SystemBootParameters>);
Q_DECLARE_METATYPE(std::shared_ptr<SystemBootParameters>);
Q_DECLARE_METATYPE(const GameListEntry*);
Q_DECLARE_METATYPE(GPURenderer);
@ -149,7 +149,7 @@ public Q_SLOTS:
void applySettings(bool display_osd_messages = false);
void updateInputMap();
void applyInputProfile(const QString& profile_path);
void bootSystem(std::shared_ptr<const SystemBootParameters> params);
void bootSystem(std::shared_ptr<SystemBootParameters> params);
void resumeSystemFromState(const QString& filename, bool boot_on_failure);
void resumeSystemFromMostRecentState();
void powerOffSystem();