mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-28 00:04:04 -04:00
Merge pull request #5413 from rldhont/server-bugfix-display
[Server][Bugfix] Test if the environ variable DISPLAY is defined
This commit is contained in:
commit
a6964b51bc
@ -19,6 +19,8 @@
|
|||||||
//for CMAKE_INSTALL_PREFIX
|
//for CMAKE_INSTALL_PREFIX
|
||||||
#include "qgsconfig.h"
|
#include "qgsconfig.h"
|
||||||
#include "qgsserver.h"
|
#include "qgsserver.h"
|
||||||
|
#include "qgslogger.h"
|
||||||
|
#include "qgsserverlogger.h"
|
||||||
#include "qgsfcgiserverresponse.h"
|
#include "qgsfcgiserverresponse.h"
|
||||||
#include "qgsfcgiserverrequest.h"
|
#include "qgsfcgiserverrequest.h"
|
||||||
|
|
||||||
@ -39,7 +41,25 @@ int fcgi_accept()
|
|||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
QgsApplication app( argc, argv, getenv( "DISPLAY" ), QString(), QStringLiteral( "server" ) );
|
// Test if the environ variable DISPLAY is defined
|
||||||
|
// if it's not, the server is running in offscreen mode
|
||||||
|
// Qt supports using various QPA (Qt Platform Abstraction) back ends
|
||||||
|
// for rendering. You can specify the back end to use with the environment
|
||||||
|
// variable QT_QPA_PLATFORM when invoking a Qt-based application.
|
||||||
|
// Available platform plugins are: directfbegl, directfb, eglfs, linuxfb,
|
||||||
|
// minimal, minimalegl, offscreen, wayland-egl, wayland, xcb.
|
||||||
|
// https://www.ics.com/blog/qt-tips-and-tricks-part-1
|
||||||
|
// http://doc.qt.io/qt-5/qpa.html
|
||||||
|
const char *display = getenv( "DISPLAY" );
|
||||||
|
bool withDisplay = true;
|
||||||
|
if ( !display )
|
||||||
|
{
|
||||||
|
withDisplay = false;
|
||||||
|
qputenv( "QT_QPA_PLATFORM", "offscreen" );
|
||||||
|
QgsMessageLog::logMessage( "DISPLAY not set, running in offscreen mode, all printing capabilities will not be available.", "Server", QgsMessageLog::INFO );
|
||||||
|
}
|
||||||
|
// since version 3.0 QgsServer now needs a qApp so initialize QgsApplication
|
||||||
|
QgsApplication app( argc, argv, withDisplay, QString(), QStringLiteral( "server" ) );
|
||||||
QgsServer server;
|
QgsServer server;
|
||||||
#ifdef HAVE_SERVER_PYTHON_PLUGINS
|
#ifdef HAVE_SERVER_PYTHON_PLUGINS
|
||||||
server.initPython();
|
server.initPython();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user