diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index d9f3510..9bcd6db 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -895,15 +895,13 @@ bool br::Context::checkSDKPath(const QString &sdkPath) // We create our own when the user hasn't static QCoreApplication *application = NULL; -void br::Context::initialize(int &argc, char *argv[], QString sdkPath) +void br::Context::initialize(int &argc, char *argv[], QString sdkPath, bool useGui) { qInstallMessageHandler(messageHandler); -#ifdef _WIN32 - bool useGui = true; -#else // not _WIN32 - bool useGui = (getenv("DISPLAY") != NULL); -#endif // _WIN32 +#ifndef _WIN32 + useGui = useGui && (getenv("DISPLAY") != NULL); +#endif // not _WIN32 // We take in argc as a reference due to: // https://bugreports.qt-project.org/browse/QTBUG-5637 diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index fd005d2..d50a183 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -794,11 +794,12 @@ public: * By default share/openbr/openbr.bib will be searched for relative to: * -# The working directory * -# The executable's location + * \param useGui Create a QApplication instead of a QCoreApplication. * \note Tiggers \em abort() on failure to locate share/openbr/openbr.bib. * \note Qt users should instead call this after initializing QApplication. * \see finalize */ - static void initialize(int &argc, char *argv[], QString sdkPath = ""); + static void initialize(int &argc, char *argv[], QString sdkPath = "", bool useGui = true); /*! * \brief Call \em once at the end of the application to deallocate global variables.