diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 06c5a8850..0443c8b00 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -676,6 +676,11 @@ main(int argc, char *argv[]) #endif if (settings_only) { + VMManagerClientSocket manager_socket; + if (qgetenv("VMM_86BOX_SOCKET").size()) { + manager_socket.IPCConnect(qgetenv("VMM_86BOX_SOCKET")); + manager_socket.clientRunningStateChanged(VMManagerProtocol::RunningState::PausedWaiting); + } Settings settings; if (settings.exec() == QDialog::Accepted) { settings.save(); diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 87649a6a1..85db8cb4a 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -182,19 +182,6 @@ VMManagerMain::settingsButtonPressed() { return; } selected_sysconfig->launchSettings(); - // If the process is already running, the system will be instructed to open its settings window. - // Otherwise the process will be launched and will need to be tracked here. - if (!selected_sysconfig->isProcessRunning()) { - connect(selected_sysconfig->process, QOverload::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; - return; - } - selected_sysconfig->reloadConfig(); - vm_details->updateData(selected_sysconfig); - }); - } } void diff --git a/src/qt/qt_vmmanager_system.cpp b/src/qt/qt_vmmanager_system.cpp index 355f0690f..94340674a 100644 --- a/src/qt/qt_vmmanager_system.cpp +++ b/src/qt/qt_vmmanager_system.cpp @@ -418,6 +418,14 @@ VMManagerSystem::launchMainProcess() { qDebug() << Q_FUNC_INFO << " Full Command:" << process->program() << " " << process->arguments(); process->start(); updateTimestamp(); + + connect(process, QOverload::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; + return; + } + }); } void @@ -432,6 +440,15 @@ VMManagerSystem::launchSettings() { 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 @@ -454,6 +471,14 @@ VMManagerSystem::launchSettings() { process->setArguments(args); qDebug() << Q_FUNC_INFO << " Full Command:" << process->program() << " " << process->arguments(); process->start(); + + connect(process, QOverload::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; + return; + } + }); } void