Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[geonode] more robust version string parsing (fix #21093, #21140)

(cherry picked from commit 440f8d4)
  • Loading branch information
alexbruy authored and nyalldawson committed Feb 10, 2019
1 parent 385018d commit 3d12f83
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/geocms/geonode/qgsgeonoderequest.cpp
Expand Up @@ -26,6 +26,7 @@
#include <QJsonObject>
#include <QUrl>
#include <QDomDocument>
#include <QRegularExpression>

QgsGeoNodeRequest::QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent )
: QObject( parent )
Expand Down Expand Up @@ -272,9 +273,18 @@ QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( con
qint16 minorVersion;
if ( jsonVariantMap.contains( QStringLiteral( "geonode_version" ) ) )
{
const QStringList geonodeVersionSplit = jsonVariantMap.value( QStringLiteral( "geonode_version" ) ).toString().split( '.' );
majorVersion = geonodeVersionSplit.at( 0 ).toInt();
minorVersion = geonodeVersionSplit.at( 1 ).toInt();
QRegularExpression re( "((\\d+)(\\.\\d+))" );
QRegularExpressionMatch match = re.match( jsonVariantMap.value( QStringLiteral( "geonode_version" ) ).toString() );
if ( match.hasMatch() )
{
const QStringList geonodeVersionSplit = match.captured( 0 ).split( '.' );
majorVersion = geonodeVersionSplit.at( 0 ).toInt();
minorVersion = geonodeVersionSplit.at( 1 ).toInt();
}
else
{
return layers;
}
}
else
{
Expand Down

0 comments on commit 3d12f83

Please sign in to comment.