diff --git a/python/pyplugin_installer/installer_data.py b/python/pyplugin_installer/installer_data.py index cdbc2fc76df..eecd312d467 100644 --- a/python/pyplugin_installer/installer_data.py +++ b/python/pyplugin_installer/installer_data.py @@ -618,7 +618,7 @@ class Plugins(QObject): qgisMinimumVersion = pluginMetadata("qgisMinimumVersion").strip() if not qgisMinimumVersion: qgisMinimumVersion = "0" qgisMaximumVersion = pluginMetadata("qgisMaximumVersion").strip() - if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".999" + if not qgisMaximumVersion: qgisMaximumVersion = qgisMinimumVersion[0] + ".99" #if compatible, add the plugin to the list if not isCompatible(QGis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion): error = "incompatible" diff --git a/python/pyplugin_installer/version_compare.py b/python/pyplugin_installer/version_compare.py index 358d6271571..49f2627b792 100644 --- a/python/pyplugin_installer/version_compare.py +++ b/python/pyplugin_installer/version_compare.py @@ -121,21 +121,9 @@ def compareVersions(a,b): b = normalizeVersion(b) if a == b: return 0 - # convert the strings to the lists + # convert the strings to lists v1 = chopString(a) v2 = chopString(b) - - # !! ensure the version contains at least 3 segments. Fill to "x.y.z with "999" segments if needed. - # 999 must me unicode because of isnumeric method used. - if len(v1) == 2: - v1 += [u"999"] - elif len(v1) == 1: - v1 += [u"999",u"999"] - if len(v2) == 2: - v2 += [u"999"] - elif len(v2) == 1: - v2 += [u"999",u"999"] - # set the shorter string as a base l = len(v1) if l > len(v2): @@ -159,9 +147,10 @@ def compareVersions(a,b): - - -## COMPARE CURRENT QGIS VERSION WITH qgisMinimumVersion AND qgisMaximumVersion """ +""" +COMPARE CURRENT QGIS VERSION WITH qgisMinimumVersion AND qgisMaximumVersion +ALLOWED FORMATS ARE: major.minor OR major.minor.bugfix, where each segment must be 0..99 +""" def splitVersion(s): """ split string into 2 or 3 numerical segments """ @@ -171,7 +160,7 @@ def splitVersion(s): for c in l: if not c.isnumeric(): return None - if int(c)>999: + if int(c)>99: return None if len(l) not in [2,3]: return None @@ -188,7 +177,7 @@ def isCompatible(curVer, minVer, maxVer=None): return False if not maxVer: - maxVer = [minVer[0], "999", "999"] + maxVer = [minVer[0], "99", "99"] if len(minVer)<3: minVer += ["0"] @@ -197,10 +186,10 @@ def isCompatible(curVer, minVer, maxVer=None): curVer += ["0"] if len(maxVer)<3: - maxVer += ["999"] + maxVer += ["99"] - minVer = "%03d%03d%03d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) ) - maxVer = "%03d%03d%03d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) ) - curVer = "%03d%03d%03d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) ) + minVer = "%02d%02d%02d" % ( int(minVer[0]), int(minVer[1]), int(minVer[2]) ) + maxVer = "%02d%02d%02d" % ( int(maxVer[0]), int(maxVer[1]), int(maxVer[2]) ) + curVer = "%02d%02d%02d" % ( int(curVer[0]), int(curVer[1]), int(curVer[2]) ) return ( minVer <= curVer and maxVer >= curVer) diff --git a/src/app/qgspluginregistry.cpp b/src/app/qgspluginregistry.cpp index 3d4d575311d..92bd195c438 100644 --- a/src/app/qgspluginregistry.cpp +++ b/src/app/qgspluginregistry.cpp @@ -207,11 +207,11 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion } // Parse qgisMaxVersion. Must be in form x.y.z or just x.y - int maxVerMajor, maxVerMinor, maxVerBugfix = 999; + int maxVerMajor, maxVerMinor, maxVerBugfix = 99; if ( maxVersion.isEmpty() || maxVersion == "__error__" ) { maxVerMajor = minVerMajor; - maxVerMinor = 999; + maxVerMinor = 99; } else { @@ -252,16 +252,16 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion int qgisMinor = qgisVersionParts.at( 1 ).toInt(); int qgisBugfix = qgisVersionParts.at( 2 ).toInt(); - // build strings with trailing zeroes - QString minVer = QString( "%1%2%3" ).arg( minVerMajor, 3, 10, QChar( '0' ) ) - .arg( minVerMinor, 3, 10, QChar( '0' ) ) - .arg( minVerBugfix, 3, 10, QChar( '0' ) ); - QString maxVer = QString( "%1%2%3" ).arg( maxVerMajor, 3, 10, QChar( '0' ) ) - .arg( maxVerMinor, 3, 10, QChar( '0' ) ) - .arg( maxVerBugfix, 3, 10, QChar( '0' ) ); - QString curVer = QString( "%1%2%3" ).arg( qgisMajor, 3, 10, QChar( '0' ) ) - .arg( qgisMinor, 3, 10, QChar( '0' ) ) - .arg( qgisBugfix, 3, 10, QChar( '0' ) ); + // build XxYyZz strings with trailing zeroes if needed + QString minVer = QString( "%1%2%3" ).arg( minVerMajor, 2, 10, QChar( '0' ) ) + .arg( minVerMinor, 2, 10, QChar( '0' ) ) + .arg( minVerBugfix, 2, 10, QChar( '0' ) ); + QString maxVer = QString( "%1%2%3" ).arg( maxVerMajor, 2, 10, QChar( '0' ) ) + .arg( maxVerMinor, 2, 10, QChar( '0' ) ) + .arg( maxVerBugfix, 2, 10, QChar( '0' ) ); + QString curVer = QString( "%1%2%3" ).arg( qgisMajor, 2, 10, QChar( '0' ) ) + .arg( qgisMinor, 2, 10, QChar( '0' ) ) + .arg( qgisBugfix, 2, 10, QChar( '0' ) ); // compare return ( minVer <= curVer && maxVer >= curVer); diff --git a/src/app/qgspluginregistry.h b/src/app/qgspluginregistry.h index c068e827f1d..0d6bfa8a48e 100644 --- a/src/app/qgspluginregistry.h +++ b/src/app/qgspluginregistry.h @@ -103,7 +103,7 @@ class QgsPluginRegistry bool checkPythonPlugin( QString packageName ); //! Check current QGIS version against requested minimal and optionally maximal QGIS version - //! if maxVersion not specified, the default value is assumed: floor(minVersion) + 0.999.999 + //! if maxVersion not specified, the default value is assumed: floor(minVersion) + 0.99.99 bool checkQgisVersion( QString minVersion, QString maxVersion = "" ); private: