mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-28 06:25:42 -04: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<QtHostInterface> host_interface = std::make_unique<QtHostInterface>();
|
||||||
std::unique_ptr<SystemBootParameters> boot_params;
|
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;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
if (!host_interface->Initialize())
|
if (!host_interface->Initialize())
|
||||||
@ -48,8 +48,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
if (boot_params)
|
if (boot_params)
|
||||||
{
|
{
|
||||||
host_interface->bootSystem(*boot_params);
|
host_interface->bootSystem(std::move(boot_params));
|
||||||
boot_params.reset();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -269,15 +269,12 @@ void MainWindow::onStartDiscActionTriggered()
|
|||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SystemBootParameters boot_params;
|
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(filename.toStdString()));
|
||||||
boot_params.filename = filename.toStdString();
|
|
||||||
m_host_interface->bootSystem(boot_params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onStartBIOSActionTriggered()
|
void MainWindow::onStartBIOSActionTriggered()
|
||||||
{
|
{
|
||||||
SystemBootParameters boot_params;
|
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>());
|
||||||
m_host_interface->bootSystem(boot_params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onChangeDiscFromFileActionTriggered()
|
void MainWindow::onChangeDiscFromFileActionTriggered()
|
||||||
@ -391,9 +388,7 @@ void MainWindow::onGameListEntryDoubleClicked(const GameListEntry* entry)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SystemBootParameters boot_params;
|
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(path.toStdString()));
|
||||||
boot_params.filename = path.toStdString();
|
|
||||||
m_host_interface->bootSystem(boot_params);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -429,19 +424,20 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(menu.addAction(tr("Default Boot")), &QAction::triggered,
|
connect(menu.addAction(tr("Default Boot")), &QAction::triggered, [this, entry]() {
|
||||||
[this, entry]() { m_host_interface->bootSystem(SystemBootParameters(entry->path)); });
|
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(entry->path));
|
||||||
|
});
|
||||||
|
|
||||||
connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() {
|
connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() {
|
||||||
SystemBootParameters boot_params(entry->path);
|
auto boot_params = std::make_shared<SystemBootParameters>(entry->path);
|
||||||
boot_params.override_fast_boot = true;
|
boot_params->override_fast_boot = true;
|
||||||
m_host_interface->bootSystem(boot_params);
|
m_host_interface->bootSystem(std::move(boot_params));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(menu.addAction(tr("Full Boot")), &QAction::triggered, [this, entry]() {
|
connect(menu.addAction(tr("Full Boot")), &QAction::triggered, [this, entry]() {
|
||||||
SystemBootParameters boot_params(entry->path);
|
auto boot_params = std::make_shared<SystemBootParameters>(entry->path);
|
||||||
boot_params.override_fast_boot = false;
|
boot_params->override_fast_boot = false;
|
||||||
m_host_interface->bootSystem(boot_params);
|
m_host_interface->bootSystem(std::move(boot_params));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -44,7 +44,7 @@ Log_SetChannel(QtHostInterface);
|
|||||||
|
|
||||||
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
|
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<SystemBootParameters>();
|
qRegisterMetaType<std::shared_ptr<const SystemBootParameters>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtHostInterface::~QtHostInterface()
|
QtHostInterface::~QtHostInterface()
|
||||||
@ -171,12 +171,6 @@ bool QtHostInterface::ConfirmMessage(const char* message)
|
|||||||
return result;
|
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,
|
std::string QtHostInterface::GetStringSettingValue(const char* section, const char* key,
|
||||||
const char* default_value /*= ""*/)
|
const char* default_value /*= ""*/)
|
||||||
{
|
{
|
||||||
@ -344,16 +338,17 @@ void QtHostInterface::setMainWindow(MainWindow* window)
|
|||||||
m_main_window = window;
|
m_main_window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::bootSystem(const SystemBootParameters& params)
|
void QtHostInterface::bootSystem(std::shared_ptr<const SystemBootParameters> params)
|
||||||
{
|
{
|
||||||
if (!isOnWorkerThread())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit emulationStarting();
|
emit emulationStarting();
|
||||||
BootSystem(params);
|
BootSystem(*params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::resumeSystemFromState(const QString& filename, bool boot_on_failure)
|
void QtHostInterface::resumeSystemFromState(const QString& filename, bool boot_on_failure)
|
||||||
|
@ -30,7 +30,7 @@ class INISettingsInterface;
|
|||||||
class MainWindow;
|
class MainWindow;
|
||||||
class QtDisplayWidget;
|
class QtDisplayWidget;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(SystemBootParameters);
|
Q_DECLARE_METATYPE(std::shared_ptr<const SystemBootParameters>);
|
||||||
|
|
||||||
class QtHostInterface final : public QObject, public CommonHostInterface
|
class QtHostInterface final : public QObject, public CommonHostInterface
|
||||||
{
|
{
|
||||||
@ -49,8 +49,6 @@ public:
|
|||||||
void ReportMessage(const char* message) override;
|
void ReportMessage(const char* message) override;
|
||||||
bool ConfirmMessage(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.
|
/// Thread-safe settings access.
|
||||||
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override;
|
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;
|
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 onDisplayWindowKeyEvent(int key, bool pressed);
|
||||||
void onDisplayWindowMouseMoveEvent(int x, int y);
|
void onDisplayWindowMouseMoveEvent(int x, int y);
|
||||||
void onDisplayWindowMouseButtonEvent(int button, bool pressed);
|
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 resumeSystemFromState(const QString& filename, bool boot_on_failure);
|
||||||
void resumeSystemFromMostRecentState();
|
void resumeSystemFromMostRecentState();
|
||||||
void powerOffSystem();
|
void powerOffSystem();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user