4 changes: 2 additions & 2 deletions src/core/qgslabelsearchtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void QgsLabelSearchTree::labelsInRect( const QgsRectangle& r, QList<QgsLabelPosi
}
}

bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram, bool pinned )
bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, const QString& labeltext, bool diagram, bool pinned )
{
if ( !labelPos )
{
Expand All @@ -84,7 +84,7 @@ bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, co
cornerPoints.push_back( QgsPoint( labelPos->getX( i ), labelPos->getY( i ) ) );
}
QgsLabelPosition* newEntry = new QgsLabelPosition( featureId, labelPos->getAlpha(), cornerPoints, QgsRectangle( c_min[0], c_min[1], c_max[0], c_max[1] ),
labelPos->getWidth(), labelPos->getHeight(), layerName, labelPos->getUpsideDown(), diagram, pinned );
labelPos->getWidth(), labelPos->getHeight(), layerName, labeltext, labelPos->getUpsideDown(), diagram, pinned );
mSpatialIndex.Insert( c_min, c_max, newEntry );
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgslabelsearchtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CORE_EXPORT QgsLabelSearchTree
* @return true in case of success
* @note not available in python bindings
*/
bool insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram = false, bool pinned = false );
bool insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, const QString& labeltext, bool diagram = false, bool pinned = false );

private:
RTree<QgsLabelPosition*, double, 2, double> mSpatialIndex;
Expand Down
7 changes: 4 additions & 3 deletions src/core/qgsmaprenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ class QgsDiagramLayerSettings;
class CORE_EXPORT QgsLabelPosition
{
public:
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, bool upside_down, bool diagram = false, bool pinned = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, const QString& labeltext, bool upside_down, bool diagram = false, bool pinned = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), labelText( labeltext ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), labelText( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
int featureId;
double rotation;
QVector< QgsPoint > cornerPoints;
QgsRectangle labelRect;
double width;
double height;
QString layerID;
QString labelText;
bool upsideDown;
bool isDiagram;
bool isPinned;
Expand Down
5 changes: 3 additions & 2 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ void QgsPalLabeling::drawLabeling( QgsRenderContext& context )
//for diagrams, remove the additional 'd' at the end of the layer id
QString layerId = layerNameUtf8;
layerId.chop( 1 );
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), layerId, true, false );
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), QString( "" ) , layerId, true, false );
}
continue;
}
Expand Down Expand Up @@ -1690,7 +1690,8 @@ void QgsPalLabeling::drawLabeling( QgsRenderContext& context )

if ( mLabelSearchTree )
{
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), ( *it )->getLayerName(), false, palGeometry->isPinned() );
QString labeltext = (( QgsPalGeometry* )( *it )->getFeaturePart()->getUserGeometry() )->text();
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), ( *it )->getLayerName(), labeltext, false, palGeometry->isPinned() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5190,7 +5190,7 @@ void QgsVectorLayer::redoEditCommand( QgsUndoCommand* cmd )
if ( !FID_IS_NEW( fid ) )
{
// existing feature
if ( attrChIt.value().target.isNull() )
if ( !attrChIt.value().target.isValid() )
{
mChangedAttributeValues[fid].remove( attrChIt.key() );
if ( mChangedAttributeValues[fid].isEmpty() )
Expand Down