Skip to content

Commit 18451fd

Browse files
committed
fix #4622
1 parent 7f7f61e commit 18451fd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/qgsexpression.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <QtDebug>
1919
#include <QDomDocument>
2020
#include <QSettings>
21+
2122
#include <math.h>
23+
#include <limits>
2224

2325
#include "qgsdistancearea.h"
2426
#include "qgsfeature.h"
@@ -136,13 +138,16 @@ static double getDoubleValue( const QVariant& value, QgsExpression* parent )
136138
static int getIntValue( const QVariant& value, QgsExpression* parent )
137139
{
138140
bool ok;
139-
int x = value.toInt( &ok );
140-
if ( !ok )
141+
qint64 x = value.toLongLong(&ok);
142+
if ( ok && x >= std::numeric_limits<int>::min() && x <= std::numeric_limits<int>::max() )
143+
{
144+
return x;
145+
}
146+
else
141147
{
142148
parent->setEvalErrorString( QObject::tr( "Cannot convert '%1' to int" ).arg( value.toString() ) );
143149
return 0;
144150
}
145-
return x;
146151
}
147152

148153

0 commit comments

Comments
 (0)