Skip to content

Commit

Permalink
Merge pull request #3854 from elpaso/plugin-re-enable
Browse files Browse the repository at this point in the history
[SERVER][BUGFIX] Plugin re enable
  • Loading branch information
elpaso authored Dec 10, 2016
2 parents fc8493f + bcedb6d commit 91b03a9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/server/qgis_map_serv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ int main( int argc, char * argv[] )
{
QgsApplication app( argc, argv, getenv( "DISPLAY" ), QString(), QStringLiteral( "server" ) );
QgsServer server( false );
#ifdef HAVE_SERVER_PYTHON_PLUGINS
server.initPython();
#endif
// Starts FCGI loop
while ( fcgi_accept() >= 0 )
{
Expand Down
37 changes: 19 additions & 18 deletions src/server/qgsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ QgsCapabilitiesCache* QgsServer::sCapabilitiesCache = nullptr;
QgsMapRenderer* QgsServer::sMapRenderer = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsServerInterfaceImpl*QgsServer::sServerInterface = nullptr;
bool QgsServer::sInitPython = true;
#endif
// Initialization must run once for all servers
bool QgsServer::sInitialised = false;
Expand Down Expand Up @@ -316,10 +315,6 @@ bool QgsServer::init( )
return false;
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
sInitPython = false;
#endif

QgsServerLogger::instance();

#ifndef _MSC_VER
Expand Down Expand Up @@ -398,28 +393,19 @@ bool QgsServer::init( )
QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Roman" ) << QStringLiteral( "Bold" ) );
#endif

QgsEditorWidgetRegistry::initEditors();

#ifdef HAVE_SERVER_PYTHON_PLUGINS
sServerInterface = new QgsServerInterfaceImpl( sCapabilitiesCache );
if ( sInitPython )
{
// Init plugins
if ( ! QgsServerPlugins::initPlugins( sServerInterface ) )
{
QgsMessageLog::logMessage( QStringLiteral( "No server python plugins are available" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "Server python plugins loaded" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
}
#endif

QgsEditorWidgetRegistry::initEditors();
sInitialised = true;
QgsMessageLog::logMessage( QStringLiteral( "Server initialized" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
return true;
}



void QgsServer::putenv( const QString &var, const QString &val )
{
#ifdef _MSC_VER
Expand Down Expand Up @@ -645,6 +631,21 @@ QPair<QByteArray, QByteArray> QgsServer::handleRequest( const QString& queryStri
return theRequestHandler->getResponse();
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
void QgsServer::initPython()
{
// Init plugins
if ( ! QgsServerPlugins::initPlugins( sServerInterface ) )
{
QgsMessageLog::logMessage( QStringLiteral( "No server python plugins are available" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "Server python plugins loaded" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
}
#endif

#if 0
// The following code was used to test type conversion in python bindings
QPair<QByteArray, QByteArray> QgsServer::testQPair( QPair<QByteArray, QByteArray> pair )
Expand Down
7 changes: 5 additions & 2 deletions src/server/qgsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ class SERVER_EXPORT QgsServer
QPair<QByteArray, QByteArray> testQPair( QPair<QByteArray, QByteArray> pair );
#endif

//! Returns a pointer to the server interface
#ifdef HAVE_SERVER_PYTHON_PLUGINS
//! Returns a pointer to the server interface
QgsServerInterfaceImpl* serverInterface() { return sServerInterface; }

//! Intialize python
//! Note: not in python bindings
void initPython( );
#endif

private:
Expand Down Expand Up @@ -120,7 +124,6 @@ class SERVER_EXPORT QgsServer
static QgsMapRenderer* sMapRenderer;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
static QgsServerInterfaceImpl* sServerInterface;
static bool sInitPython;
#endif
//! Initialization must run once for all servers
static bool sInitialised;
Expand Down

0 comments on commit 91b03a9

Please sign in to comment.