Skip to content

Commit

Permalink
Merge pull request #41109 from elpaso/bugfix-gh41076-OGR-NULL-empty-s…
Browse files Browse the repository at this point in the history
…trings-on-winzozz

Fixes windows issue with QVariant( QString() ) being NULL
  • Loading branch information
elpaso authored and github-actions[bot] committed Jan 21, 2021
1 parent 5084507 commit c3c1328
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/qgsogrutils.cpp
Expand Up @@ -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( "" ) ); // skip-keyword-check
#endif

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

return value;
Expand Down

0 comments on commit c3c1328

Please sign in to comment.