Skip to content
Permalink
Browse files

Merge pull request #3127 from sbrunner/add-version-warning

Add a warning on QGIS server when the versions don't corresponds
  • Loading branch information
mhugent committed Jun 6, 2016
2 parents f279183 + e5253f8 commit 056a6be82468390fb61e4c10c0c442200f24b3cc
@@ -591,7 +591,7 @@ static void _getTitle( QDomDocument const &doc, QString &title )
@returns the version string or an empty string if none found
*/
static QgsProjectVersion _getVersion( QDomDocument const &doc )
QgsProjectVersion getVersion( QDomDocument const &doc )
{
QDomNodeList nl = doc.elementsByTagName( "qgis" );

@@ -606,7 +606,7 @@ static QgsProjectVersion _getVersion( QDomDocument const &doc )
QDomElement qgisElement = qgisNode.toElement(); // qgis node should be element
QgsProjectVersion projectVersion( qgisElement.attribute( "version" ) );
return projectVersion;
} // _getVersion
} // getVersion



@@ -861,7 +861,7 @@ bool QgsProject::read()
QgsDebugMsg( "Project title: " + imp_->title );

// get project version string, if any
QgsProjectVersion fileVersion = _getVersion( *doc );
QgsProjectVersion fileVersion = getVersion( *doc );
QgsProjectVersion thisVersion( QGis::QGIS_VERSION );

if ( thisVersion > fileVersion )
@@ -530,4 +530,6 @@ class CORE_EXPORT QgsProjectBadLayerDefaultHandler : public QgsProjectBadLayerHa

};

CORE_EXPORT QgsProjectVersion getVersion( QDomDocument const &doc );

#endif
@@ -62,6 +62,15 @@ bool QgsProjectVersion::operator==( const QgsProjectVersion &other ) const
( mSub == other.mSub ) );
}

/** Boolean equal operator
*/
bool QgsProjectVersion::operator!=( const QgsProjectVersion &other ) const
{
return (( mMajor != other.mMajor ) ||
( mMinor != other.mMinor ) ||
( mSub != other.mSub ) );
}

/** Boolean >= operator
*/
bool QgsProjectVersion::operator>=( const QgsProjectVersion &other ) const
@@ -49,6 +49,10 @@ class CORE_EXPORT QgsProjectVersion
*/
bool operator==( const QgsProjectVersion &other ) const;

/** Boolean equal operator
*/
bool operator!=( const QgsProjectVersion &other ) const;

/** Boolean >= operator
*/
bool operator>=( const QgsProjectVersion &other ) const;
@@ -23,6 +23,7 @@
#include "qgswmsprojectparser.h"
#include "qgssldconfigparser.h"
#include "qgsaccesscontrol.h"
#include "qgsproject.h"

#include <QFile>

@@ -47,11 +48,37 @@ QgsConfigCache::~QgsConfigCache()

QgsServerProjectParser* QgsConfigCache::serverConfiguration( const QString& filePath )
{
QgsMessageLog::logMessage(
QString( "Open the project file '%1'." )
.arg( filePath ),
"Server", QgsMessageLog::INFO
);

QDomDocument* doc = xmlDocument( filePath );
if ( !doc )
{
return nullptr;
}

QgsProjectVersion fileVersion = getVersion( *doc );
QgsProjectVersion thisVersion( QGis::QGIS_VERSION );

if ( thisVersion != fileVersion )
{
QgsMessageLog::logMessage(
QString(
"\n========================================================================="
"\n= WARNING: This project file was saved by an defferent version of QGIS. ="
"\n========================================================================="
), "Server", QgsMessageLog::WARNING
);
}
QgsMessageLog::logMessage(
QString( "QGIS server version %1, project version %2" )
.arg( thisVersion.text() )
.arg( fileVersion.text() ),
"Server", QgsMessageLog::INFO
);
return new QgsServerProjectParser( doc, filePath );
}

0 comments on commit 056a6be

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