Replace GEOS function calls by QgsGeometry class methods

OK, I have changed it, and a possible memory leak below
thanks!


>________________________________
> De: Martin Dobias <notifications@github.com>
>Para: qgis/QGIS <QGIS@noreply.github.com> 
>CC: Alvaro Huarte <ahuarte47@yahoo.es> 
>Enviado: Viernes 13 de junio de 2014 12:08
>Asunto: Re: [QGIS] Replace GEOS function calls by QgsGeometry class methods (#1451)
> 
>
>
>In src/core/qgspallabeling.cpp:
>> @@ -1927,7 +1927,16 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
>    // fix invalid polygons
>    if ( geom->type() == QGis::Polygon && !geom->isGeosValid() )
>    {
> -    geom->fromGeos( GEOSBuffer( geom->asGeos(), 0, 0 ) );
> +    QgsGeometry* bufferGeom = geom->buffer( 0, 0 );
> +
> +    if ( bufferGeom )
> +    {
> +      size_t wkbSize = bufferGeom->wkbSize();
> +      unsigned char* wkb = ( unsigned char* )malloc( wkbSize );
> +      memcpy( wkb, bufferGeom->asWkb(), wkbSize );
> +      geom->fromWkb( wkb, wkbSize );
> +      delete bufferGeom;
> +    } 
>I have realized that there's potentially a problem here: 'geom' variable may be a pointer directly from QgsFeature. We shall not modify the feature's geometry in place - we need to create a clone like when doing coordinate transform earlier in the same function. I understand that we are not really changing the shape, just fixing the geometry, but the geometry data should not be modified at all. Ideally the feature should be passed around as "const" reference - something to fix in QGIS 3.
>—
>Reply to this email directly or view it on GitHub.
>
>