summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-20 11:21:56 +0100
committerSimon Rettberg2023-01-20 11:21:56 +0100
commitab0a11f177091855d9c6488ab999daeadc6e9b9c (patch)
tree199b7db441422394a4db04741514549158111665 /src
parentMdernize CMakeLists.txt build type handling (diff)
downloadpvs2-ab0a11f177091855d9c6488ab999daeadc6e9b9c.tar.gz
pvs2-ab0a11f177091855d9c6488ab999daeadc6e9b9c.tar.xz
pvs2-ab0a11f177091855d9c6488ab999daeadc6e9b9c.zip
[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()
Diffstat (limited to 'src')
-rw-r--r--src/server/main.cpp3
-rw-r--r--src/server/serverapp/serverapp.cpp11
-rw-r--r--src/server/serverapp/serverapp.h5
3 files changed, 11 insertions, 8 deletions
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 <QDebug>
@@ -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 <QTranslator>
#include <QNetworkInterface>
#include <QSettings>
#include <QLibraryInfo>
-#include "serverapp.h"
-#include "../../shared/util.h"
-
static QSize minimalGridSize(const QMap<QString, QPoint>& 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 <QApplication>
#include <QStringList>
#include <QMap>
@@ -49,6 +47,7 @@ private:
QByteArray _sessionNameArray;
QMap<QString, Room*> _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