Skip to content
Permalink
Browse files

Add comment on detach use

  • Loading branch information
nyalldawson committed Nov 10, 2018
1 parent a234bf7 commit 51587209ac9b2a4fa173380f33899d52d801344f
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/core/qgsogrutils.cpp
@@ -226,8 +226,12 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField
{
int size = 0;
const GByte *b = OGR_F_GetFieldAsBinary( ogrFet, attIndex, &size );

// QByteArray::fromRawData is funny. It doesn't take ownership of the data, so we have to explicitly call
// detach on it to force a copy which owns the data
QByteArray ba = QByteArray::fromRawData( reinterpret_cast<const char *>( b ), size );
ba.detach();

value = ba;
break;
}

0 comments on commit 5158720

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