Skip to content

Commit 3d12f83

Browse files
alexbruynyalldawson
authored andcommittedFeb 10, 2019
[geonode] more robust version string parsing (fix #21093, #21140)
(cherry picked from commit 440f8d4)
1 parent 385018d commit 3d12f83

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed
 

‎src/core/geocms/geonode/qgsgeonoderequest.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <QJsonObject>
2727
#include <QUrl>
2828
#include <QDomDocument>
29+
#include <QRegularExpression>
2930

3031
QgsGeoNodeRequest::QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent )
3132
: QObject( parent )
@@ -272,9 +273,18 @@ QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( con
272273
qint16 minorVersion;
273274
if ( jsonVariantMap.contains( QStringLiteral( "geonode_version" ) ) )
274275
{
275-
const QStringList geonodeVersionSplit = jsonVariantMap.value( QStringLiteral( "geonode_version" ) ).toString().split( '.' );
276-
majorVersion = geonodeVersionSplit.at( 0 ).toInt();
277-
minorVersion = geonodeVersionSplit.at( 1 ).toInt();
276+
QRegularExpression re( "((\\d+)(\\.\\d+))" );
277+
QRegularExpressionMatch match = re.match( jsonVariantMap.value( QStringLiteral( "geonode_version" ) ).toString() );
278+
if ( match.hasMatch() )
279+
{
280+
const QStringList geonodeVersionSplit = match.captured( 0 ).split( '.' );
281+
majorVersion = geonodeVersionSplit.at( 0 ).toInt();
282+
minorVersion = geonodeVersionSplit.at( 1 ).toInt();
283+
}
284+
else
285+
{
286+
return layers;
287+
}
278288
}
279289
else
280290
{

0 commit comments

Comments
 (0)