Skip to content

Commit

Permalink
traymon: do not initialize GUI for connection test
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Dec 11, 2018
1 parent 1ae73b9 commit 11ffdaa
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions core/src/qt-tray-monitor/tray-monitor.cc
Expand Up @@ -34,10 +34,12 @@
#include "monitoritemthread.h"
#include "lib/bsignal.h"

ConfigurationParser *my_config = nullptr; /* Our Global config */
ConfigurationParser *my_config = nullptr;

/* Static variables */
static QApplication* app = NULL;
/* QCoreApplication* app will be initialized with:
* - QApplication for normal execution with a GUI or
* - QCoreApplication for tests when no GUI must be used */
static QCoreApplication* app = nullptr;

static void usage()
{
Expand Down Expand Up @@ -157,12 +159,12 @@ static void cleanup()

if(app) {
delete app;
app = NULL;
app = nullptr;
}

if (my_config) {
delete my_config;
my_config = NULL;
my_config = nullptr;
}

WSACleanup(); /* Cleanup Windows sockets */
Expand Down Expand Up @@ -223,8 +225,14 @@ int main(int argc, char *argv[])
Emsg0(M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n"));
}

app = new QApplication(argc, argv);
app->setQuitOnLastWindowClosed(false);
if (cl.do_connection_test_only_) {
/* do not initialize a GUI */
app = new QCoreApplication(argc, argv);
} else {
QApplication *p = new QApplication(argc, argv);
p->setQuitOnLastWindowClosed(false);
app = p;
}

if (!cl.do_connection_test_only_) {
setupQtObjects();
Expand Down

0 comments on commit 11ffdaa

Please sign in to comment.