add: if ( !data ) return QString::null;
context: static QString asUtf8( const QByteArray &val ){  const char *data = val.data();  //QString::fromUtf8() bug workaround  if ( data[ val.size() - 1 ] == '\0' )     return QString::fromUtf8( data, val.size() - 1 );  else    return QString::fromUtf8( data, val.size() );}