diff options
-rw-r--r-- | src/server/main.cpp | 3 | ||||
-rw-r--r-- | src/server/serverapp/serverapp.cpp | 11 | ||||
-rw-r--r-- | src/server/serverapp/serverapp.h | 5 |
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 |