Skip to content

Commit 7fb27d4

Browse files
committedAug 27, 2015
[GRASS] allow major version only in qgm version_min/max
1 parent 55aed10 commit 7fb27d4

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed
 

‎src/plugins/grass/qgsgrassmoduleparam.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,11 @@ bool QgsGrassModuleOption::checkVersion( const QString& version_min, const QStri
368368

369369
bool minOk = true;
370370
bool maxOk = true;
371+
QRegExp rxVersionMajor( "(\\d+)" );
371372
QRegExp rxVersion( "(\\d+)\\.(\\d+)" );
372373
if ( !version_min.isEmpty() )
373374
{
374-
if ( !rxVersion.exactMatch( version_min ) )
375-
{
376-
errors << tr( "Cannot parse version_min %1" ).arg( version_min );
377-
}
378-
else
375+
if ( rxVersion.exactMatch( version_min ) )
379376
{
380377
int versionMajorMin = rxVersion.cap( 1 ).toInt();
381378
int versionMinorMin = rxVersion.cap( 2 ).toInt();
@@ -384,15 +381,23 @@ bool QgsGrassModuleOption::checkVersion( const QString& version_min, const QStri
384381
minOk = false;
385382
}
386383
}
384+
else if ( rxVersionMajor.exactMatch( version_min ) )
385+
{
386+
int versionMajorMin = rxVersionMajor.cap( 1 ).toInt();
387+
if ( QgsGrass::versionMajor() < versionMajorMin )
388+
{
389+
minOk = false;
390+
}
391+
}
392+
else
393+
{
394+
errors << tr( "Cannot parse version_min %1" ).arg( version_min );
395+
}
387396
}
388397

389398
if ( !version_max.isEmpty() )
390399
{
391-
if ( !rxVersion.exactMatch( version_max ) )
392-
{
393-
errors << tr( "Cannot parse version_max %1" ).arg( version_max );
394-
}
395-
else
400+
if ( rxVersion.exactMatch( version_max ) )
396401
{
397402
int versionMajorMax = rxVersion.cap( 1 ).toInt();
398403
int versionMinorMax = rxVersion.cap( 2 ).toInt();
@@ -401,6 +406,18 @@ bool QgsGrassModuleOption::checkVersion( const QString& version_min, const QStri
401406
maxOk = false;
402407
}
403408
}
409+
else if ( rxVersionMajor.exactMatch( version_max ) )
410+
{
411+
int versionMajorMax = rxVersionMajor.cap( 1 ).toInt();
412+
if ( QgsGrass::versionMajor() > versionMajorMax )
413+
{
414+
maxOk = false;
415+
}
416+
}
417+
else
418+
{
419+
errors << tr( "Cannot parse version_max %1" ).arg( version_max );
420+
}
404421
}
405422
return errors.isEmpty() && minOk && maxOk;
406423
}

0 commit comments

Comments
 (0)
Please sign in to comment.