Skip to content
Permalink
Browse files

Merge pull request #1714 from manisandro/intsafe_doublesafe

Fix isIntSafe and isDoubleSafe not considering some QVariant types
  • Loading branch information
m-kuhn committed Dec 1, 2014
2 parents 974511f + 29d0166 commit 823d45a37c35d01c98949ce137e0c1c65b3a2a53
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/core/qgsexpression.cpp
@@ -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;
}

0 comments on commit 823d45a

Please sign in to comment.
You can’t perform that action at this time.