Skip to content

Commit

Permalink
Moved static vars to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Feb 23, 2016
1 parent 5e8feb6 commit 1c177d0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/server/qgsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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" );
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/server/qgsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

17 changes: 13 additions & 4 deletions src/server/qgsserverplugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand All @@ -118,3 +126,4 @@ bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
return mPythonUtils && mPythonUtils->isEnabled() && atLeastOneEnabled;
}


2 changes: 1 addition & 1 deletion src/server/qgsserverplugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.