Skip to content

Commit

Permalink
Merge pull request #1714 from manisandro/intsafe_doublesafe
Browse files Browse the repository at this point in the history
Fix isIntSafe and isDoubleSafe not considering some QVariant types
  • Loading branch information
m-kuhn committed Dec 1, 2014
2 parents 974511f + 29d0166 commit 823d45a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -162,13 +162,20 @@ static QVariant tvl2variant( TVL v )
inline bool isIntSafe( const QVariant& v )
{
if ( v.type() == QVariant::Int ) return true;
if ( v.type() == QVariant::UInt ) return true;
if ( v.type() == QVariant::LongLong ) return true;
if ( v.type() == QVariant::ULongLong ) return true;
if ( v.type() == QVariant::Double ) return false;
if ( v.type() == QVariant::String ) { bool ok; v.toString().toInt( &ok ); return ok; }
return false;
}
inline bool isDoubleSafe( const QVariant& v )
{
if ( v.type() == QVariant::Double || v.type() == QVariant::Int ) return true;
if ( v.type() == QVariant::Double ) return true;
if ( v.type() == QVariant::Int ) return true;
if ( v.type() == QVariant::UInt ) return true;
if ( v.type() == QVariant::LongLong ) return true;
if ( v.type() == QVariant::ULongLong ) return true;
if ( v.type() == QVariant::String ) { bool ok; v.toString().toDouble( &ok ); return ok; }
return false;
}
Expand Down

0 comments on commit 823d45a

Please sign in to comment.