|
@@ -68,31 +68,25 @@ bool QgsServer::sInitPython = true; |
|
|
#endif |
|
|
// Initialization must run once for all servers |
|
|
bool QgsServer::sInitialised = false; |
|
|
char* QgsServer::sArgv[1]; |
|
|
int QgsServer::sArgc; |
|
|
QgsApplication* QgsServer::sQgsApplication = nullptr; |
|
|
bool QgsServer::sCaptureOutput = false; |
|
|
bool QgsServer::sCaptureOutput = true; |
|
|
|
|
|
|
|
|
|
|
|
QgsServer::QgsServer( int &argc, char **argv ) |
|
|
{ |
|
|
init( argc, argv ); |
|
|
saveEnvVars(); |
|
|
} |
|
|
|
|
|
|
|
|
QgsServer::QgsServer() |
|
|
QgsServer::QgsServer( bool captureOutput ) |
|
|
{ |
|
|
// Must be already instanciated |
|
|
if ( qApp == nullptr ) |
|
|
{ |
|
|
abort(); |
|
|
} |
|
|
sCaptureOutput = captureOutput; |
|
|
init(); |
|
|
saveEnvVars(); |
|
|
} |
|
|
|
|
|
|
|
|
QgsServer::~QgsServer() |
|
|
{ |
|
|
if ( sQgsApplication ) |
|
|
sQgsApplication->exitQgis(); |
|
|
} |
|
|
|
|
|
|
|
@@ -310,34 +304,18 @@ QString QgsServer::configPath( const QString& defaultConfigPath, const QMap<QStr |
|
|
|
|
|
|
|
|
/** |
|
|
* This is used in python bindings only |
|
|
* Server initialization |
|
|
*/ |
|
|
bool QgsServer::init() |
|
|
bool QgsServer::init( ) |
|
|
{ |
|
|
if ( sInitialised ) |
|
|
{ |
|
|
return false; |
|
|
} |
|
|
|
|
|
sArgv[0] = serverName().toUtf8().data(); |
|
|
sArgc = 1; |
|
|
sCaptureOutput = true; |
|
|
#ifdef HAVE_SERVER_PYTHON_PLUGINS |
|
|
sInitPython = false; |
|
|
#endif |
|
|
return init( sArgc , sArgv ); |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* Server initialization |
|
|
*/ |
|
|
bool QgsServer::init( int & argc, char ** argv ) |
|
|
{ |
|
|
if ( sInitialised ) |
|
|
{ |
|
|
return false; |
|
|
} |
|
|
|
|
|
QgsServerLogger::instance(); |
|
|
|
|
@@ -353,8 +331,6 @@ bool QgsServer::init( int & argc, char ** argv ) |
|
|
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optionsPath ); |
|
|
} |
|
|
|
|
|
sQgsApplication = new QgsApplication( argc, argv, getenv( "DISPLAY" ), QString(), "server" ); |
|
|
|
|
|
QCoreApplication::setOrganizationName( QgsApplication::QGIS_ORGANIZATION_NAME ); |
|
|
QCoreApplication::setOrganizationDomain( QgsApplication::QGIS_ORGANIZATION_DOMAIN ); |
|
|
QCoreApplication::setApplicationName( QgsApplication::QGIS_APPLICATION_NAME ); |
|
@@ -410,7 +386,6 @@ bool QgsServer::init( int & argc, char ** argv ) |
|
|
// Store the config file path |
|
|
sConfigFilePath = new QString( defaultConfigFilePath ); |
|
|
|
|
|
|
|
|
//create cache for capabilities XML |
|
|
sCapabilitiesCache = new QgsCapabilitiesCache(); |
|
|
sMapRenderer = new QgsMapRenderer; |
|
@@ -482,7 +457,8 @@ QPair<QByteArray, QByteArray> QgsServer::handleRequest( const QString& queryStri |
|
|
// performances and memory in the long run |
|
|
sMapRenderer->rendererContext()->setExpressionContext( QgsExpressionContext() ); |
|
|
|
|
|
sQgsApplication->processEvents(); |
|
|
qApp->processEvents(); |
|
|
|
|
|
if ( logLevel < 1 ) |
|
|
{ |
|
|
time.start(); |
|
|