Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[server][windows] Fix crash on startup
  • Loading branch information
m-kuhn committed Dec 20, 2019
1 parent e1068e6 commit ffd42d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 16 additions & 15 deletions src/server/qgsserver.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -226,7 +227,7 @@ bool QgsServer::init()
initLocale();

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

setupNetworkAccessManager();
QDomImplementation::setInvalidDataPolicy( QDomImplementation::DropInvalidChars );
Expand Down Expand Up @@ -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";
Expand All @@ -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 )
Expand Down
2 changes: 0 additions & 2 deletions src/server/qgsserver.h
Expand Up @@ -140,8 +140,6 @@ class SERVER_EXPORT QgsServer
//! service registry
static QgsServiceRegistry *sServiceRegistry;

static QgsServerSettings sSettings;

//! cache
QgsConfigCache *mConfigCache = nullptr;

Expand Down

0 comments on commit ffd42d9

Please sign in to comment.