From ab0a11f177091855d9c6488ab999daeadc6e9b9c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 20 Jan 2023 11:21:56 +0100 Subject: [pvsmgr] Fix app-exit in --manager-only mode on Qt5.15 In newer Qt versions, calling QApplication::exit() in the App constructor deadlocks the application. Set a flag instead and exit from main() --- src/server/main.cpp | 3 ++- src/server/serverapp/serverapp.cpp | 11 ++++++----- src/server/serverapp/serverapp.h | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/server/main.cpp b/src/server/main.cpp index d975f80..7ae0466 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -1,4 +1,3 @@ -#include "mainwindow/mainwindow.h" #include "serverapp/serverapp.h" #include @@ -21,6 +20,8 @@ void usage() int main(int argc, char** argv) { ServerApp app(argc, argv); + if (app.shouldExit()) + return 0; for (QString a : app.arguments()) { if (a == "--usage" || a == "--help") { diff --git a/src/server/serverapp/serverapp.cpp b/src/server/serverapp/serverapp.cpp index 933517b..900d3a4 100644 --- a/src/server/serverapp/serverapp.cpp +++ b/src/server/serverapp/serverapp.cpp @@ -1,11 +1,12 @@ +#include "../mainwindow/mainwindow.h" +#include "serverapp.h" +#include "../../shared/util.h" + #include #include #include #include -#include "serverapp.h" -#include "../../shared/util.h" - static QSize minimalGridSize(const QMap& clientPositions, QSize& clientSize); ServerApp::ServerApp(int& argc, char** argv) @@ -21,8 +22,8 @@ ServerApp::ServerApp(int& argc, char** argv) // If started in manager-only mode, and there is no current room // after reading the config, exit right away - if (_managerOnly && _currentRoom == "") { - QApplication::exit(0); + if (_managerOnly && _currentRoom.isEmpty()) { + _doExit = true; return; } diff --git a/src/server/serverapp/serverapp.h b/src/server/serverapp/serverapp.h index b2b16c5..3cb40b5 100644 --- a/src/server/serverapp/serverapp.h +++ b/src/server/serverapp/serverapp.h @@ -1,8 +1,6 @@ #ifndef SERVERAPP_H #define SERVERAPP_H -#include "../mainwindow/mainwindow.h" - #include #include #include @@ -49,6 +47,7 @@ private: QByteArray _sessionNameArray; QMap _rooms; QString _currentRoom; + bool _doExit{}; bool _managerOnly{}; bool _isExam{}; @@ -78,6 +77,8 @@ public: void setCurrentRoom(const QString& room) { _currentRoom = room; } void setExam(bool exam) { _isExam = exam; } + bool shouldExit() const { return _doExit; } + }; #endif -- cgit v1.2.3-55-g7522