Add comment on detach use

This commit is contained in:
Nyall Dawson 2018-11-10 12:05:37 +10:00
parent a234bf7f4d
commit 51587209ac

View File

@ -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;
}