Manager: Pass asset path to VMs if specified on command line (#6569)

* Manager: Pass asset path to VMs if specified on command line

* Manager: Merge `VMManagerSystem::launchSettings` into `VMManagerSystem::launchMainProcess`
This commit is contained in:
Alexander Babikov
2025-12-17 21:53:48 +05:00
committed by GitHub
parent 73f531a8f9
commit 7800bcd0bd
3 changed files with 19 additions and 62 deletions

View File

@@ -159,9 +159,10 @@ extern int confirm_exit_cmdl; /* (O) do not ask for confirmation on quit if set
extern uint64_t unique_id;
extern uint64_t source_hwnd;
#endif
extern char rom_path[1024]; /* (O) full path to ROMs */
extern char log_path[1024]; /* (O) full path of logfile */
extern char vm_name[1024]; /* (O) display name of the VM */
extern char rom_path[1024]; /* (O) full path to ROMs */
extern char asset_path[1024]; /* (O) full path to assets */
extern char log_path[1024]; /* (O) full path of logfile */
extern char vm_name[1024]; /* (O) display name of the VM */
#ifdef USE_INSTRUMENT
extern uint8_t instru_enabled;
extern uint64_t instru_run_ms;

View File

@@ -392,9 +392,8 @@ VMManagerSystem::has86BoxBinary()
}
void
VMManagerSystem::launchMainProcess()
VMManagerSystem::launch86Box(bool settings)
{
if (!has86BoxBinary()) {
qWarning("No binary found! returning");
return;
@@ -408,22 +407,31 @@ VMManagerSystem::launchMainProcess()
return;
}
}
// If the system is already running, bring it to front
// If the system is already running, bring it to front or instruct it to show settings
if (process->processId() != 0) {
#ifdef Q_OS_WINDOWS
if (this->id) {
SetForegroundWindow((HWND) this->id);
}
#endif
if (settings)
socket_server->serverSendMessage(VMManagerProtocol::ManagerMessage::ShowSettings);
return;
}
// Otherwise, launch the system
setProcessEnvVars();
window_obscured = settings;
QString program = main_binary.filePath();
QStringList args;
args << "--vmpath" << config_dir;
args << "--vmname" << displayName;
if (settings)
args << "--settings";
if (rom_path[0] != '\0')
args << "--rompath" << QString(rom_path);
if (asset_path[0] != '\0')
args << "--assetpath" << QString(asset_path);
if (global_cfg_overridden)
args << "--global" << QString(global_cfg_path);
if (!hook_enabled)
@@ -442,7 +450,7 @@ VMManagerSystem::launchMainProcess()
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[=](const int exitCode, const QProcess::ExitStatus exitStatus) {
if (exitCode != 0 || exitStatus != QProcess::NormalExit) {
qInfo().nospace().noquote() << "Abnormal program termination while launching main process: exit code " << exitCode << ", exit status " << exitStatus;
qInfo().nospace().noquote() << "Abnormal program termination while launching system: exit code " << exitCode << ", exit status " << exitStatus;
QMessageBox::critical(this, tr("Virtual machine crash"),
tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString("%1 (0x%2)").arg(QString::number(exitCode), QString::number(exitCode, 16))));
return;
@@ -455,65 +463,13 @@ VMManagerSystem::launchMainProcess()
void
VMManagerSystem::startButtonPressed()
{
launchMainProcess();
launch86Box(false);
}
void
VMManagerSystem::launchSettings()
{
if (!has86BoxBinary()) {
qWarning("No binary found! returning");
return;
}
// start the server first to get the socket name
if (!serverIsRunning) {
if (!startServer()) {
// FIXME: Better error handling
qInfo("Failed to start VM Manager server");
return;
}
}
// If the system is already running, instruct it to show settings
if (process->processId() != 0) {
#ifdef Q_OS_WINDOWS
if (this->id) {
SetForegroundWindow((HWND) this->id);
}
#endif
socket_server->serverSendMessage(VMManagerProtocol::ManagerMessage::ShowSettings);
return;
}
// Otherwise, launch the system with the settings parameter
setProcessEnvVars();
window_obscured = true;
QString program = main_binary.filePath();
QStringList open_command_args;
QStringList args;
args << "--vmpath" << config_dir << "--settings";
if (rom_path[0] != '\0')
args << "--rompath" << QString(rom_path);
if (global_cfg_overridden)
args << "--global" << QString(global_cfg_path);
process->setProgram(program);
process->setArguments(args);
qDebug() << Q_FUNC_INFO << " Full Command:" << process->program() << " " << process->arguments();
process->start();
disconnect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), nullptr, nullptr);
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[=](const int exitCode, const QProcess::ExitStatus exitStatus) {
if (exitCode != 0 || exitStatus != QProcess::NormalExit) {
qInfo().nospace().noquote() << "Abnormal program termination while launching settings: exit code " << exitCode << ", exit status " << exitStatus;
QMessageBox::critical(this, tr("Virtual machine crash"),
tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString("%1 (0x%2)").arg(QString::number(exitCode), QString::number(exitCode, 16))));
return;
}
configurationChangeReceived();
});
launch86Box(true);
}
void

View File

@@ -120,7 +120,7 @@ public:
[[nodiscard]] bool isProcessRunning() const;
[[nodiscard]] qint64 processId() const;
public slots:
void launchMainProcess();
void launch86Box(bool settings = false);
void launchSettings();
void startButtonPressed();
void restartButtonPressed();