Skip to content
Permalink
Browse files

Merge pull request #33491 from m-kuhn/windows-server-crash-fix

[server][windows] Fix crash on startup
  • Loading branch information
m-kuhn committed Dec 20, 2019
2 parents 2371b5d + ffd42d9 commit 602febc39f385609204ada110852c54e24e835ee
Showing with 16 additions and 17 deletions.
  1. +16 −15 src/server/qgsserver.cpp
  2. +0 −2 src/server/qgsserver.h
@@ -59,10 +59,11 @@ QgsCapabilitiesCache *QgsServer::sCapabilitiesCache = nullptr;
QgsServerInterfaceImpl *QgsServer::sServerInterface = nullptr;
// Initialization must run once for all servers
bool QgsServer::sInitialized = false;
QgsServerSettings QgsServer::sSettings;

QgsServiceRegistry *QgsServer::sServiceRegistry = nullptr;

Q_GLOBAL_STATIC( QgsServerSettings, sSettings );

QgsServer::QgsServer()
{
// QgsApplication must exist
@@ -92,8 +93,8 @@ void QgsServer::setupNetworkAccessManager()
QSettings settings;
QgsNetworkAccessManager *nam = QgsNetworkAccessManager::instance();
QNetworkDiskCache *cache = new QNetworkDiskCache( nullptr );
qint64 cacheSize = sSettings.cacheSize();
QString cacheDirectory = sSettings.cacheDirectory();
qint64 cacheSize = sSettings()->cacheSize();
QString cacheDirectory = sSettings()->cacheDirectory();
cache->setCacheDirectory( cacheDirectory );
cache->setMaximumCacheSize( cacheSize );
QgsMessageLog::logMessage( QStringLiteral( "cacheDirectory: %1" ).arg( cache->cacheDirectory() ), QStringLiteral( "Server" ), Qgis::Info );
@@ -137,7 +138,7 @@ void QgsServer::printRequestParameters( const QMap< QString, QString> &parameter
QString QgsServer::configPath( const QString &defaultConfigPath, const QString &configPath )
{
QString cfPath( defaultConfigPath );
QString projectFile = sSettings.projectFile();
QString projectFile = sSettings()->projectFile();
if ( !projectFile.isEmpty() )
{
cfPath = projectFile;
@@ -170,13 +171,13 @@ QString QgsServer::configPath( const QString &defaultConfigPath, const QString &
void QgsServer::initLocale()
{
// System locale override
if ( ! sSettings.overrideSystemLocale().isEmpty() )
if ( ! sSettings()->overrideSystemLocale().isEmpty() )
{
QLocale::setDefault( QLocale( sSettings.overrideSystemLocale() ) );
QLocale::setDefault( QLocale( sSettings()->overrideSystemLocale() ) );
}
// Number group separator settings
QLocale currentLocale;
if ( sSettings.showGroupSeparator() )
if ( sSettings()->showGroupSeparator() )
{
currentLocale.setNumberOptions( currentLocale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
}
@@ -208,16 +209,16 @@ bool QgsServer::init()

// reload settings to take into account QCoreApplication and QgsApplication
// configuration
sSettings.load();
sSettings()->load();

// init and configure logger
QgsServerLogger::instance();
QgsServerLogger::instance()->setLogLevel( sSettings.logLevel() );
if ( ! sSettings.logFile().isEmpty() )
QgsServerLogger::instance()->setLogLevel( sSettings()->logLevel() );
if ( ! sSettings()->logFile().isEmpty() )
{
QgsServerLogger::instance()->setLogFile( sSettings.logFile() );
QgsServerLogger::instance()->setLogFile( sSettings()->logFile() );
}
else if ( sSettings.logStderr() )
else if ( sSettings()->logStderr() )
{
QgsServerLogger::instance()->setLogStderr();
}
@@ -226,7 +227,7 @@ bool QgsServer::init()
initLocale();

// log settings currently used
sSettings.logSummary();
sSettings()->logSummary();

setupNetworkAccessManager();
QDomImplementation::setInvalidDataPolicy( QDomImplementation::DropInvalidChars );
@@ -273,7 +274,7 @@ bool QgsServer::init()

sServiceRegistry = new QgsServiceRegistry();

sServerInterface = new QgsServerInterfaceImpl( sCapabilitiesCache, sServiceRegistry, &sSettings );
sServerInterface = new QgsServerInterfaceImpl( sCapabilitiesCache, sServiceRegistry, sSettings() );

// Load service module
QString modulePath = QgsApplication::libexecPath() + "server";
@@ -294,7 +295,7 @@ void QgsServer::putenv( const QString &var, const QString &val )
#else
setenv( var.toStdString().c_str(), val.toStdString().c_str(), 1 );
#endif
sSettings.load( var );
sSettings()->load( var );
}

void QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project )
@@ -140,8 +140,6 @@ class SERVER_EXPORT QgsServer
//! service registry
static QgsServiceRegistry *sServiceRegistry;

static QgsServerSettings sSettings;

//! cache
QgsConfigCache *mConfigCache = nullptr;

0 comments on commit 602febc

Please sign in to comment.
You can’t perform that action at this time.