From 58563d36ca6a3ce94ba2c8a9f52b504ee2e60526 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Mon, 30 Dec 2024 11:26:31 -0500 Subject: [PATCH] fix: Stop core process when mode changes in gui --- src/apps/deskflow-gui/MainWindow.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index bb55b426c..e15cd37a3 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -1077,12 +1077,16 @@ void MainWindow::enableServer(bool enable) if (enable) { ui->btnToggleCore->setEnabled(true); m_actionStartCore->setEnabled(true); + + if (m_CoreProcess.isStarted() && m_CoreProcess.mode() != CoreProcess::Mode::Server) + m_CoreProcess.stop(); + m_CoreProcess.setMode(CoreProcess::Mode::Server); // The server can run without any clients configured, and this is actually // what you'll want to do the first time since you'll be prompted when an // unrecognized client tries to connect. - if (!m_AppConfig.startedBefore()) { + if (!m_AppConfig.startedBefore() && !m_CoreProcess.isStarted()) { qDebug() << "auto-starting core server for first time"; m_CoreProcess.start(); messages::showFirstServerStartMessage(this); @@ -1102,6 +1106,8 @@ void MainWindow::enableClient(bool enable) if (enable) { ui->btnToggleCore->setEnabled(true); m_actionStartCore->setEnabled(true); + if (m_CoreProcess.isStarted() && m_CoreProcess.mode() != CoreProcess::Mode::Client) + m_CoreProcess.stop(); m_CoreProcess.setMode(CoreProcess::Mode::Client); } }