Skip to content

Commit

Permalink
Server: fix unreported project storage not supported with -p
Browse files Browse the repository at this point in the history
-p only supported filesystem storage this PR fixes this
behavior by initializing providers before the project
is loaded and by attempting a project read instead of
just checking for the file.

Backported from master 545dcac
  • Loading branch information
elpaso authored and nyalldawson committed May 31, 2021
1 parent e2f4fc6 commit af93382
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/server/qgis_mapserver.cpp
Expand Up @@ -177,11 +177,14 @@ int main( int argc, char *argv[] )
qputenv( "QGIS_SERVER_LOG_LEVEL", logLevel.toUtf8() );
qputenv( "QGIS_SERVER_LOG_STDERR", "1" );

// Create server
QTcpServer tcpServer;

if ( ! parser.value( projectOption ).isEmpty( ) )
{
// Check it!
const QString projectFilePath { parser.value( projectOption ) };
if ( ! QFile::exists( projectFilePath ) )
if ( ! QgsProject::instance()->read( projectFilePath, QgsProject::ReadFlag::FlagDontResolveLayers | QgsProject::ReadFlag::FlagDontLoadLayouts | QgsProject::ReadFlag::FlagDontStoreOriginalStyles ) )
{
std::cout << QObject::tr( "Project file not found, the option will be ignored." ).toStdString() << std::endl;
}
Expand All @@ -194,8 +197,6 @@ int main( int argc, char *argv[] )
// Disable parallel rendering because if its internal loop
//qputenv( "QGIS_SERVER_PARALLEL_RENDERING", "0" );

// Create server
QTcpServer tcpServer;

QHostAddress address { QHostAddress::AnyIPv4 };
address.setAddress( ipAddress );
Expand Down

0 comments on commit af93382

Please sign in to comment.