Skip to content
Permalink
Browse files

Fixes windows issue with QVariant( QString() ) being NULL

Fixes #41076

(cherry picked from commit b078be6)
  • Loading branch information
elpaso authored and nyalldawson committed Feb 19, 2021
1 parent e5a4e04 commit 1f8298ffb1cd9b24235cc6f627d4da5cf591add0
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/core/qgsogrutils.cpp
@@ -225,6 +225,14 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField
value = QVariant( encoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attIndex ) ) );
else
value = QVariant( QString::fromUtf8( OGR_F_GetFieldAsString( ogrFet, attIndex ) ) );

#ifdef Q_OS_WIN
// Fixes GH #41076 (empty strings shown as NULL), because we have checked before that it was NOT NULL
// Note: QVariant( QString( ) ).isNull( ) is still true on windows so we really need string literal :(
if ( value.isNull() )
value = QVariant( QStringLiteral( "" ) );
#endif

break;
}
case QVariant::Int:
@@ -315,7 +323,7 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField
}
else
{
value = QVariant( QString() );
value = QVariant( field.type() );
}

return value;

0 comments on commit 1f8298f

Please sign in to comment.