Skip to content

Commit aa2014d

Browse files
committedApr 25, 2016
Fix crash in testqgsogrutils with QT5 where QTextCodec::codecForName( "System" ) returns null
1 parent 8e7691a commit aa2014d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎src/core/qgsogrutils.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ QgsFields QgsOgrUtils::readOgrFields( OGRFeatureH ogrFet, QTextCodec* encoding )
7272
continue;
7373
}
7474

75-
QString name = encoding->toUnicode( OGR_Fld_GetNameRef( fldDef ) );
75+
QString name = encoding ? encoding->toUnicode( OGR_Fld_GetNameRef( fldDef ) ) : QString::fromUtf8( OGR_Fld_GetNameRef( fldDef ) );
7676
QVariant::Type varType;
7777
switch ( OGR_Fld_GetType( fldDef ) )
7878
{
@@ -137,8 +137,13 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField
137137
switch ( fields.at( attIndex ).type() )
138138
{
139139
case QVariant::String:
140-
value = QVariant( encoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attIndex ) ) );
140+
{
141+
if ( encoding )
142+
value = QVariant( encoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attIndex ) ) );
143+
else
144+
value = QVariant( QString::fromUtf8( OGR_F_GetFieldAsString( ogrFet, attIndex ) ) );
141145
break;
146+
}
142147
case QVariant::Int:
143148
value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attIndex ) );
144149
break;

0 commit comments

Comments
 (0)
Please sign in to comment.