Skip to content
Permalink
Browse files

Fix crashing rule-based labeling with data-defined properties (fixes #…

…13416)

This code has been funded by Tuscany Region (Italy) - SITA (CIG: 63526840AE) and commissioned to Gis3W s.a.s.
  • Loading branch information
wonder-sk committed Sep 29, 2015
1 parent 7e61616 commit 5b0bfc6238bf1e66aad9460b3456314f3ffe9df9
Showing with 26 additions and 11 deletions.
  1. +21 −2 src/core/qgspallabeling.cpp
  2. +5 −0 src/core/qgspallabeling.h
  3. +0 −9 src/core/qgsvectorlayerlabelprovider.cpp
@@ -332,6 +332,14 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
, showingShadowRects( false )
, expression( NULL )
{
*this = s;
}

QgsPalLayerSettings& QgsPalLayerSettings::operator=( const QgsPalLayerSettings & s )
{
if ( this == &s )
return *this;

// copy only permanent stuff

enabled = s.enabled;
@@ -461,12 +469,17 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
shadowBlendMode = s.shadowBlendMode;

// data defined
dataDefinedProperties = s.dataDefinedProperties;
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator it = s.dataDefinedProperties.constBegin();
for ( ; it != s.dataDefinedProperties.constEnd(); ++it )
{
dataDefinedProperties.insert( it.key(), it.value() ? new QgsDataDefined( *it.value() ) : 0 );
}
mDataDefinedNames = s.mDataDefinedNames;

// scale factors
vectorScaleFactor = s.vectorScaleFactor;
rasterCompressFactor = s.rasterCompressFactor;
return *this;
}


@@ -478,7 +491,13 @@ QgsPalLayerSettings::~QgsPalLayerSettings()
delete expression;
delete extentGeom;

// clear pointers to QgsDataDefined objects
// delete all QgsDataDefined objects (which also deletes their QgsExpression object)
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::iterator it = dataDefinedProperties.begin();
for ( ; it != dataDefinedProperties.constEnd(); ++it )
{
delete( it.value() );
it.value() = 0;
}
dataDefinedProperties.clear();
}

@@ -67,6 +67,9 @@ class CORE_EXPORT QgsPalLayerSettings
QgsPalLayerSettings( const QgsPalLayerSettings& s );
~QgsPalLayerSettings();

//! copy operator - only copies the permanent members
QgsPalLayerSettings &operator=( const QgsPalLayerSettings & s );

//! @note added in 2.4
static QgsPalLayerSettings fromLayer( QgsVectorLayer* layer );

@@ -534,6 +537,8 @@ class CORE_EXPORT QgsPalLayerSettings
bool dataDefinedUseExpression( QgsPalLayerSettings::DataDefinedProperties p ) const;

/** Map of current data defined properties
*
* Pointers to QgsDataDefined should never be null, the pointers are owned by this class
*/
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > dataDefinedProperties;

@@ -102,15 +102,6 @@ void QgsVectorLayerLabelProvider::init()

QgsVectorLayerLabelProvider::~QgsVectorLayerLabelProvider()
{
// delete all QgsDataDefined objects (which also deletes their QgsExpression object)
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::iterator it = mSettings.dataDefinedProperties.begin();
for ( ; it != mSettings.dataDefinedProperties.constEnd(); ++it )
{
delete( it.value() );
it.value() = 0;
}
mSettings.dataDefinedProperties.clear();

qDeleteAll( mLabels );

if ( mOwnsSource )

0 comments on commit 5b0bfc6

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