Skip to content
Permalink
Browse files

Moved static vars to functions

  • Loading branch information
elpaso committed Feb 22, 2016
1 parent 5e8feb6 commit 1c177d0d4682e791640b5c3c3424232624f1031d
Showing with 24 additions and 8 deletions.
  1. +8 −2 src/server/qgsserver.cpp
  2. +2 −1 src/server/qgsserver.h
  3. +13 −4 src/server/qgsserverplugins.cpp
  4. +1 −1 src/server/qgsserverplugins.h
@@ -57,7 +57,6 @@
// Static initialisers, default values for fcgi server
QgsApplication* QgsServer::mQgsApplication = nullptr;
bool QgsServer::mInitialised = false;
QString QgsServer::mServerName( "qgis_server" );
bool QgsServer::mCaptureOutput = false;
char* QgsServer::mArgv[1];
int QgsServer::mArgc = 1;
@@ -81,6 +80,13 @@ QgsServer::~QgsServer()
}


QString& QgsServer::serverName()
{
static QString* name = new QString( "qgis_server" );
return *name;
}


QFileInfo QgsServer::defaultAdminSLD()
{
return QFileInfo( "admin.sld" );
@@ -296,7 +302,7 @@ bool QgsServer::init()
{
return false;
}
mArgv[0] = mServerName.toUtf8().data();
mArgv[0] = serverName().toUtf8().data();
mArgc = 1;
mCaptureOutput = true;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
@@ -115,11 +115,12 @@ class SERVER_EXPORT QgsServer
static bool mInitPython;
#endif
static bool mInitialised;
static QString mServerName;
static char* mArgv[1];
static int mArgc;
static QgsApplication* mQgsApplication;
static bool mCaptureOutput;
// Return the server name
static QString &serverName();
};
#endif // QGSSERVER_H

@@ -26,14 +26,22 @@

#include <QLibrary>


// Initialize static members
QgsPythonUtils* QgsServerPlugins::mPythonUtils;


QgsServerPlugins::QgsServerPlugins()
{
}


// Initialize static members
QgsPythonUtils* QgsServerPlugins::mPythonUtils;
// Initialize static members
QStringList QgsServerPlugins::mServerPlugins;
QStringList &QgsServerPlugins::serverPlugins()
{
static QStringList* pluginList = new QStringList();
return *pluginList;
}

// This code is mainly borrowed from QGIS desktop Python plugin initialization
bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
@@ -101,7 +109,7 @@ bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
if ( mPythonUtils->startServerPlugin( pluginName ) )
{
atLeastOneEnabled = true;
mServerPlugins.append( pluginName );
serverPlugins().append( pluginName );
QgsMessageLog::logMessage( QString( "Server plugin %1 loaded!" ).arg( pluginName ), "Server", QgsMessageLog::INFO );
}
else
@@ -118,3 +126,4 @@ bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
return mPythonUtils && mPythonUtils->isEnabled() && atLeastOneEnabled;
}


@@ -40,7 +40,7 @@ class SERVER_EXPORT QgsServerPlugins
//! Pointer to QgsPythonUtils
static QgsPythonUtils* mPythonUtils;
//! List of available server plugin names
static QStringList mServerPlugins;
static QStringList& serverPlugins();
};

#endif // QGSSERVERPLUGINS_H

0 comments on commit 1c177d0

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