Skip to content

Commit a0cb645

Browse files
authoredFeb 4, 2017
Merge pull request #4095 from nyalldawson/label_engine_layers
Use weak layer pointers in labeling engine
2 parents 11150dd + 615745f commit a0cb645

21 files changed

+71
-107
lines changed
 

‎src/core/annotations/qgsannotation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class CORE_EXPORT QgsAnnotation : public QObject
348348
QPointF mBalloonSegmentPoint2;
349349

350350
//! Associated layer (or nullptr if not attached to a layer)
351-
QPointer<QgsMapLayer> mMapLayer;
351+
QgsWeakMapLayerPointer mMapLayer;
352352

353353
//! Associated feature, or invalid feature if no feature associated
354354
QgsFeature mFeature;

‎src/core/composer/qgscomposermap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ bool QgsComposerMap::writeXml( QDomElement& elem, QDomDocument & doc ) const
12311231

12321232
//layer set
12331233
QDomElement layerSetElem = doc.createElement( QStringLiteral( "LayerSet" ) );
1234-
Q_FOREACH ( const QPointer<QgsMapLayer>& layerPtr, mLayers )
1234+
Q_FOREACH ( const QgsWeakMapLayerPointer& layerPtr, mLayers )
12351235
{
12361236
QgsMapLayer* layer = layerPtr.data();
12371237
if ( !layer )
@@ -1557,7 +1557,7 @@ void QgsComposerMap::setLayerStyleOverrides( const QMap<QString, QString>& overr
15571557
void QgsComposerMap::storeCurrentLayerStyles()
15581558
{
15591559
mLayerStyleOverrides.clear();
1560-
Q_FOREACH ( const QPointer<QgsMapLayer>& layerPtr, mLayers )
1560+
Q_FOREACH ( const QgsWeakMapLayerPointer& layerPtr, mLayers )
15611561
{
15621562
if ( QgsMapLayer* layer = layerPtr.data() )
15631563
{

‎src/core/composer/qgscomposermap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "qgsrectangle.h"
2424
#include "qgscoordinatereferencesystem.h"
2525
#include "qgsrendercontext.h"
26+
#include "qgsmaplayer.h"
2627
#include <QFont>
2728
#include <QGraphicsRectItem>
2829

@@ -542,7 +543,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
542543
bool mKeepLayerSet;
543544

544545
//! Stored layer list (used if layer live-link mKeepLayerSet is disabled)
545-
QList< QPointer<QgsMapLayer> > mLayers;
546+
QgsWeakMapLayerPointerList mLayers;
546547

547548
bool mKeepLayerStyles;
548549
//! Stored style names (value) to be used with particular layer IDs (key) instead of default style

‎src/core/qgsexpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static QgsExpression::Node* getNode( const QVariant& value, QgsExpression* paren
332332

333333
QgsVectorLayer* getVectorLayer( const QVariant& value, QgsExpression* )
334334
{
335-
QgsMapLayer* ml = value.value< QPointer<QgsMapLayer> >().data();
335+
QgsMapLayer* ml = value.value< QgsWeakMapLayerPointer >().data();
336336
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( ml );
337337
if ( !vl )
338338
{

‎src/core/qgsexpressioncontext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ QgsExpressionContextScope* QgsExpressionContextUtils::layerScope( const QgsMapLa
760760

761761
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layer_name" ), layer->name(), true ) );
762762
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layer_id" ), layer->id(), true ) );
763-
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layer" ), QVariant::fromValue<QPointer<QgsMapLayer> >( QPointer<QgsMapLayer>( const_cast<QgsMapLayer*>( layer ) ) ), true ) );
763+
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layer" ), QVariant::fromValue<QgsWeakMapLayerPointer >( QgsWeakMapLayerPointer( const_cast<QgsMapLayer*>( layer ) ) ), true ) );
764764

765765
const QgsVectorLayer* vLayer = dynamic_cast< const QgsVectorLayer* >( layer );
766766
if ( vLayer )

‎src/core/qgslabelingengine.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "pal.h"
2626
#include "problem.h"
2727
#include "qgsrendercontext.h"
28+
#include "qgsmaplayer.h"
2829

2930

3031
// helper function for checking for job cancelation within PAL
@@ -88,20 +89,20 @@ QgsLabelingEngine::~QgsLabelingEngine()
8889
qDeleteAll( mSubProviders );
8990
}
9091

91-
QStringList QgsLabelingEngine::participatingLayerIds() const
92+
QList< QgsMapLayer* > QgsLabelingEngine::participatingLayers() const
9293
{
93-
QSet< QString > ids;
94+
QSet< QgsMapLayer* > layers;
9495
Q_FOREACH ( QgsAbstractLabelProvider* provider, mProviders )
9596
{
96-
if ( !provider->layerId().isEmpty() )
97-
ids << provider->layerId();
97+
if ( provider->layer() )
98+
layers << provider->layer();
9899
}
99100
Q_FOREACH ( QgsAbstractLabelProvider* provider, mSubProviders )
100101
{
101-
if ( !provider->layerId().isEmpty() )
102-
ids << provider->layerId();
102+
if ( provider->layer() )
103+
layers << provider->layer();
103104
}
104-
return ids.toList();
105+
return layers.toList();
105106
}
106107

107108
void QgsLabelingEngine::addProvider( QgsAbstractLabelProvider* provider )
@@ -230,7 +231,7 @@ void QgsLabelingEngine::run( QgsRenderContext& context )
230231
Q_FOREACH ( QgsAbstractLabelProvider* provider, mProviders )
231232
{
232233
bool appendedLayerScope = false;
233-
if ( QgsMapLayer* ml = QgsProject::instance()->mapLayer( provider->layerId() ) )
234+
if ( QgsMapLayer* ml = provider->layer() )
234235
{
235236
appendedLayerScope = true;
236237
context.expressionContext().appendScope( QgsExpressionContextUtils::layerScope( ml ) );
@@ -415,9 +416,10 @@ QgsAbstractLabelProvider*QgsLabelFeature::provider() const
415416

416417
}
417418

418-
QgsAbstractLabelProvider::QgsAbstractLabelProvider( const QString& layerId, const QString& providerId )
419+
QgsAbstractLabelProvider::QgsAbstractLabelProvider( QgsMapLayer* layer, const QString& providerId )
419420
: mEngine( nullptr )
420-
, mLayerId( layerId )
421+
, mLayerId( layer ? layer->id() : QString() )
422+
, mLayer( layer )
421423
, mProviderId( providerId )
422424
, mFlags( DrawLabels )
423425
, mPlacement( QgsPalLayerSettings::AroundPoint )

‎src/core/qgslabelingengine.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CORE_EXPORT QgsAbstractLabelProvider
4343

4444
public:
4545
//! Construct the provider with default values
46-
QgsAbstractLabelProvider( const QString& layerId = QString(), const QString& providerId = QString() );
46+
QgsAbstractLabelProvider( QgsMapLayer* layer, const QString& providerId = QString() );
4747

4848
virtual ~QgsAbstractLabelProvider() = default;
4949

@@ -75,6 +75,9 @@ class CORE_EXPORT QgsAbstractLabelProvider
7575
//! Returns ID of associated layer, or empty string if no layer is associated with the provider.
7676
QString layerId() const { return mLayerId; }
7777

78+
//! Returns the associated layer, or nullptr if no layer is associated with the provider.
79+
QgsMapLayer* layer() const { return mLayer.data(); }
80+
7881
//! Returns provider ID - useful in case there is more than one label provider within a layer
7982
//! (e.g. in case of rule-based labeling - provider ID = rule's key). May be empty string if
8083
//! layer ID is sufficient for identification of provider's configuration.
@@ -106,6 +109,8 @@ class CORE_EXPORT QgsAbstractLabelProvider
106109
QString mName;
107110
//! Associated layer's ID, if applicable
108111
QString mLayerId;
112+
//! Weak pointer to source layer
113+
QgsWeakMapLayerPointer mLayer;
109114
//! Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling)
110115
QString mProviderId;
111116
//! Flags altering drawing and registration of features
@@ -187,10 +192,10 @@ class CORE_EXPORT QgsLabelingEngine
187192
const QgsMapSettings& mapSettings() const { return mMapSettings; }
188193

189194
/**
190-
* Returns a list of layer IDs for layers with providers in the engine.
195+
* Returns a list of layers with providers in the engine.
191196
* @note added in QGIS 3.0
192197
*/
193-
QStringList participatingLayerIds() const;
198+
QList< QgsMapLayer* > participatingLayers() const;
194199

195200
//! Add provider of label features. Takes ownership of the provider
196201
void addProvider( QgsAbstractLabelProvider* provider );

‎src/core/qgsmaplayer.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,4 +920,18 @@ class CORE_EXPORT QgsMapLayer : public QObject
920920

921921
Q_DECLARE_METATYPE( QgsMapLayer* )
922922

923+
/**
924+
* Weak pointer for QgsMapLayer
925+
* @note added in QGIS 3.0
926+
* @note not available in Python bindings
927+
*/
928+
typedef QPointer< QgsMapLayer > QgsWeakMapLayerPointer;
929+
930+
/**
931+
* A list of weak pointers to QgsMapLayers.
932+
* @note added in QGIS 3.0
933+
* @note not available in Python bindings
934+
*/
935+
typedef QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList;
936+
923937
#endif

‎src/core/qgsmaplayerlistutils.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616

1717
/// @cond PRIVATE
1818

19-
inline QList<QgsMapLayer*> _qgis_listQPointerToRaw( const QList< QPointer<QgsMapLayer> >& layers )
19+
inline QList<QgsMapLayer*> _qgis_listQPointerToRaw( const QgsWeakMapLayerPointerList& layers )
2020
{
2121
QList<QgsMapLayer*> lst;
2222
lst.reserve( layers.count() );
23-
Q_FOREACH ( const QPointer<QgsMapLayer>& layerPtr, layers )
23+
Q_FOREACH ( const QgsWeakMapLayerPointer& layerPtr, layers )
2424
{
2525
if ( layerPtr )
2626
lst.append( layerPtr.data() );
2727
}
2828
return lst;
2929
}
3030

31-
inline QList< QPointer<QgsMapLayer> > _qgis_listRawToQPointer( const QList<QgsMapLayer*>& layers )
31+
inline QgsWeakMapLayerPointerList _qgis_listRawToQPointer( const QList<QgsMapLayer*>& layers )
3232
{
33-
QList< QPointer<QgsMapLayer> > lst;
33+
QgsWeakMapLayerPointerList lst;
3434
lst.reserve( layers.count() );
3535
Q_FOREACH ( QgsMapLayer* layer, layers )
3636
{
@@ -39,11 +39,11 @@ inline QList< QPointer<QgsMapLayer> > _qgis_listRawToQPointer( const QList<QgsMa
3939
return lst;
4040
}
4141

42-
inline QStringList _qgis_listQPointerToIDs( const QList< QPointer<QgsMapLayer> >& layers )
42+
inline QStringList _qgis_listQPointerToIDs( const QgsWeakMapLayerPointerList& layers )
4343
{
4444
QStringList lst;
4545
lst.reserve( layers.count() );
46-
Q_FOREACH ( const QPointer<QgsMapLayer>& layerPtr, layers )
46+
Q_FOREACH ( const QgsWeakMapLayerPointer& layerPtr, layers )
4747
{
4848
if ( layerPtr )
4949
lst << layerPtr->id();
@@ -93,7 +93,7 @@ inline static QgsMapLayer* _qgis_findLayer( const QList< QgsMapLayer*> layers, c
9393
}
9494
}
9595

96-
inline uint qHash( const QPointer< QgsMapLayer >& key )
96+
inline uint qHash( const QgsWeakMapLayerPointer& key )
9797
{
9898
return qHash( key ? key->id() : QString() );
9999
}

‎src/core/qgsmaprenderercache.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void QgsMapRendererCache::clearInternal()
3535
mScale = 0;
3636

3737
// make sure we are disconnected from all layers
38-
Q_FOREACH ( const QPointer< QgsMapLayer >& layer, mConnectedLayers )
38+
Q_FOREACH ( const QgsWeakMapLayerPointer& layer, mConnectedLayers )
3939
{
4040
if ( layer.data() )
4141
{
@@ -48,9 +48,9 @@ void QgsMapRendererCache::clearInternal()
4848

4949
void QgsMapRendererCache::dropUnusedConnections()
5050
{
51-
QSet< QPointer< QgsMapLayer > > stillDepends = dependentLayers();
52-
QSet< QPointer< QgsMapLayer > > disconnects = mConnectedLayers.subtract( stillDepends );
53-
Q_FOREACH ( const QPointer< QgsMapLayer >& layer, disconnects )
51+
QSet< QgsWeakMapLayerPointer > stillDepends = dependentLayers();
52+
QSet< QgsWeakMapLayerPointer > disconnects = mConnectedLayers.subtract( stillDepends );
53+
Q_FOREACH ( const QgsWeakMapLayerPointer& layer, disconnects )
5454
{
5555
if ( layer.data() )
5656
{
@@ -61,13 +61,13 @@ void QgsMapRendererCache::dropUnusedConnections()
6161
mConnectedLayers = stillDepends;
6262
}
6363

64-
QSet<QPointer<QgsMapLayer> > QgsMapRendererCache::dependentLayers() const
64+
QSet<QgsWeakMapLayerPointer > QgsMapRendererCache::dependentLayers() const
6565
{
66-
QSet< QPointer< QgsMapLayer > > result;
66+
QSet< QgsWeakMapLayerPointer > result;
6767
QMap<QString, CacheParameters>::const_iterator it = mCachedImages.constBegin();
6868
for ( ; it != mCachedImages.constEnd(); ++it )
6969
{
70-
Q_FOREACH ( const QPointer< QgsMapLayer >& l, it.value().dependentLayers )
70+
Q_FOREACH ( const QgsWeakMapLayerPointer& l, it.value().dependentLayers )
7171
{
7272
if ( l.data() )
7373
result << l;
@@ -107,7 +107,7 @@ void QgsMapRendererCache::setCacheImage( const QString& cacheKey, const QImage&
107107
if ( layer )
108108
{
109109
params.dependentLayers << layer;
110-
if ( !mConnectedLayers.contains( QPointer< QgsMapLayer >( layer ) ) )
110+
if ( !mConnectedLayers.contains( QgsWeakMapLayerPointer( layer ) ) )
111111
{
112112
connect( layer, &QgsMapLayer::repaintRequested, this, &QgsMapRendererCache::layerRequestedRepaint );
113113
mConnectedLayers << layer;

‎src/core/qgsmaprenderercache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CORE_EXPORT QgsMapRendererCache : public QObject
9999
struct CacheParameters
100100
{
101101
QImage cachedImage;
102-
QList< QPointer< QgsMapLayer > > dependentLayers;
102+
QgsWeakMapLayerPointerList dependentLayers;
103103
};
104104

105105
//! Invalidate cache contents (without locking)
@@ -108,7 +108,7 @@ class CORE_EXPORT QgsMapRendererCache : public QObject
108108
//! Disconnects from layers we no longer care about
109109
void dropUnusedConnections();
110110

111-
QSet< QPointer< QgsMapLayer > > dependentLayers() const;
111+
QSet< QgsWeakMapLayerPointer > dependentLayers() const;
112112

113113
mutable QMutex mMutex;
114114
QgsRectangle mExtent;
@@ -117,7 +117,7 @@ class CORE_EXPORT QgsMapRendererCache : public QObject
117117
//! Map of cache key to cache parameters
118118
QMap<QString, CacheParameters> mCachedImages;
119119
//! List of all layers on which this cache is currently connected
120-
QSet< QPointer< QgsMapLayer > > mConnectedLayers;
120+
QSet< QgsWeakMapLayerPointer > mConnectedLayers;
121121
};
122122

123123

‎src/core/qgsmaprendererjob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct LayerRenderJob
5050
QPainter::CompositionMode blendMode;
5151
double opacity;
5252
bool cached; // if true, img already contains cached image from previous rendering
53-
QPointer< QgsMapLayer > layer;
53+
QgsWeakMapLayerPointer layer;
5454
int renderingTime; //!< Time it took to render the layer in ms (it is -1 if not rendered or still rendering)
5555
};
5656

‎src/core/qgsmapsettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ QgsRectangle QgsMapSettings::fullExtent() const
551551
// iterate through the map layers and test each layers extent
552552
// against the current min and max values
553553
QgsDebugMsg( QString( "Layer count: %1" ).arg( mLayers.count() ) );
554-
Q_FOREACH ( const QPointer<QgsMapLayer>& layerPtr, mLayers )
554+
Q_FOREACH ( const QgsWeakMapLayerPointer& layerPtr, mLayers )
555555
{
556556
if ( QgsMapLayer* lyr = layerPtr.data() )
557557
{

‎src/core/qgsmapsettings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
#include "qgsrectangle.h"
3131
#include "qgsscalecalculator.h"
3232
#include "qgsexpressioncontext.h"
33+
#include "qgsmaplayer.h"
3334

3435
class QPainter;
3536

3637
class QgsCoordinateTransform;
3738
class QgsScaleCalculator;
3839
class QgsMapRendererJob;
39-
class QgsMapLayer;
4040

4141

4242
/** \ingroup core
@@ -310,7 +310,7 @@ class CORE_EXPORT QgsMapSettings
310310
double mMagnificationFactor;
311311

312312
//! list of layers to be rendered (stored as weak pointers)
313-
QList< QPointer<QgsMapLayer> > mLayers;
313+
QgsWeakMapLayerPointerList mLayers;
314314
QMap<QString, QString> mLayerStyleOverrides;
315315
QString mCustomRenderFlags;
316316
QgsExpressionContext mExpressionContext;

‎src/core/qgsmapthemecollection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CORE_EXPORT QgsMapThemeCollection : public QObject
8484
QSet<QString> checkedLegendItems;
8585
private:
8686
//! Weak pointer to the layer
87-
QPointer<QgsMapLayer> mLayer;
87+
QgsWeakMapLayerPointer mLayer;
8888
};
8989

9090
/**

‎src/core/qgsvectorlayerdiagramprovider.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,8 @@
2424
#include "feature.h"
2525
#include "labelposition.h"
2626

27-
28-
QgsVectorLayerDiagramProvider::QgsVectorLayerDiagramProvider(
29-
const QgsDiagramLayerSettings* diagSettings,
30-
const QgsDiagramRenderer* diagRenderer,
31-
const QString& layerId,
32-
const QgsFields& fields,
33-
const QgsCoordinateReferenceSystem& crs,
34-
QgsAbstractFeatureSource* source,
35-
bool ownsSource )
36-
: QgsAbstractLabelProvider( layerId )
37-
, mSettings( *diagSettings )
38-
, mDiagRenderer( diagRenderer->clone() )
39-
, mFields( fields )
40-
, mLayerCrs( crs )
41-
, mSource( source )
42-
, mOwnsSource( ownsSource )
43-
{
44-
init();
45-
}
46-
47-
4827
QgsVectorLayerDiagramProvider::QgsVectorLayerDiagramProvider( QgsVectorLayer* layer, bool ownFeatureLoop )
49-
: QgsAbstractLabelProvider( layer->id() )
28+
: QgsAbstractLabelProvider( layer )
5029
, mSettings( *layer->diagramLayerSettings() )
5130
, mDiagRenderer( layer->diagramRenderer()->clone() )
5231
, mFields( layer->fields() )

‎src/core/qgsvectorlayerdiagramprovider.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ class CORE_EXPORT QgsVectorLayerDiagramProvider : public QgsAbstractLabelProvide
6262
//! Convenience constructor to initialize the provider from given vector layer
6363
explicit QgsVectorLayerDiagramProvider( QgsVectorLayer* layer, bool ownFeatureLoop = true );
6464

65-
//! Construct diagram provider with all the necessary configuration parameters
66-
QgsVectorLayerDiagramProvider( const QgsDiagramLayerSettings* diagSettings,
67-
const QgsDiagramRenderer* diagRenderer,
68-
const QString& layerId,
69-
const QgsFields& fields,
70-
const QgsCoordinateReferenceSystem& crs,
71-
QgsAbstractFeatureSource* source,
72-
bool ownsSource );
73-
7465
//! Clean up
7566
~QgsVectorLayerDiagramProvider();
7667

‎src/core/qgsvectorlayerlabelprovider.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
using namespace pal;
3636

3737
QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider( QgsVectorLayer* layer, const QString& providerId, bool withFeatureLoop, const QgsPalLayerSettings* settings, const QString& layerName )
38-
: QgsAbstractLabelProvider( layer->id(), providerId )
38+
: QgsAbstractLabelProvider( layer, providerId )
3939
, mSettings( settings ? *settings : QgsPalLayerSettings::fromLayer( layer ) )
4040
, mLayerGeometryType( layer->geometryType() )
4141
, mRenderer( layer->renderer() )
@@ -58,25 +58,6 @@ QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider( QgsVectorLayer* layer,
5858
init();
5959
}
6060

61-
QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider( const QgsPalLayerSettings& settings,
62-
const QString& layerId,
63-
const QgsFields& fields,
64-
const QgsCoordinateReferenceSystem& crs,
65-
QgsAbstractFeatureSource* source,
66-
bool ownsSource, QgsFeatureRenderer* renderer )
67-
: QgsAbstractLabelProvider( layerId )
68-
, mSettings( settings )
69-
, mLayerGeometryType( QgsWkbTypes::UnknownGeometry )
70-
, mRenderer( renderer )
71-
, mFields( fields )
72-
, mCrs( crs )
73-
, mSource( source )
74-
, mOwnsSource( ownsSource )
75-
{
76-
init();
77-
}
78-
79-
8061
void QgsVectorLayerLabelProvider::init()
8162
{
8263
mPlacement = mSettings.placement;

‎src/core/qgsvectorlayerlabelprovider.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ class CORE_EXPORT QgsVectorLayerLabelProvider : public QgsAbstractLabelProvider
4444
const QgsPalLayerSettings* settings = nullptr,
4545
const QString& layerName = QString() );
4646

47-
//! Construct diagram provider with all the necessary configuration parameters
48-
QgsVectorLayerLabelProvider( const QgsPalLayerSettings& settings,
49-
const QString& layerId,
50-
const QgsFields& fields,
51-
const QgsCoordinateReferenceSystem& crs,
52-
QgsAbstractFeatureSource* source,
53-
bool ownsSource,
54-
QgsFeatureRenderer* renderer = nullptr );
55-
5647
~QgsVectorLayerLabelProvider();
5748

5849
virtual QList<QgsLabelFeature*> labelFeatures( QgsRenderContext& context ) override;

‎tests/src/core/testqgslabelingengine.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,18 @@ void TestQgsLabelingEngine::testCapitalization()
538538
void TestQgsLabelingEngine::testParticipatingLayers()
539539
{
540540
QgsLabelingEngine engine;
541-
QVERIFY( engine.participatingLayerIds().isEmpty() );
541+
QVERIFY( engine.participatingLayers().isEmpty() );
542542

543543
QgsPalLayerSettings settings1;
544544
QgsVectorLayerLabelProvider* provider = new QgsVectorLayerLabelProvider( vl, QStringLiteral( "test" ), true, &settings1 );
545545
engine.addProvider( provider );
546-
QCOMPARE( engine.participatingLayerIds(), QStringList() << vl->id() );
546+
QCOMPARE( engine.participatingLayers(), QList<QgsMapLayer*>() << vl );
547547

548548
QgsVectorLayer* layer2 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer" ), QStringLiteral( "layer2" ), QStringLiteral( "memory" ) );
549549
QgsPalLayerSettings settings2;
550550
QgsVectorLayerLabelProvider* provider2 = new QgsVectorLayerLabelProvider( layer2, QStringLiteral( "test2" ), true, &settings2 );
551551
engine.addProvider( provider2 );
552-
QCOMPARE( engine.participatingLayerIds().toSet(), QSet< QString >() << vl->id() << layer2->id() );
552+
QCOMPARE( engine.participatingLayers().toSet(), QSet< QgsMapLayer* >() << vl << layer2 );
553553

554554
// add a rule-based labeling node
555555
QgsRuleBasedLabeling::Rule* root = new QgsRuleBasedLabeling::Rule( 0 );
@@ -561,7 +561,7 @@ void TestQgsLabelingEngine::testParticipatingLayers()
561561
QgsVectorLayer* layer3 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer" ), QStringLiteral( "layer3" ), QStringLiteral( "memory" ) );
562562
QgsRuleBasedLabelProvider* ruleProvider = new QgsRuleBasedLabelProvider( QgsRuleBasedLabeling( root ), layer3 );
563563
engine.addProvider( ruleProvider );
564-
QCOMPARE( engine.participatingLayerIds().toSet(), QSet< QString >() << vl->id() << layer2->id() << layer3->id() );
564+
QCOMPARE( engine.participatingLayers().toSet(), QSet< QgsMapLayer* >() << vl << layer2 << layer3 );
565565
}
566566

567567
bool TestQgsLabelingEngine::imageCheck( const QString& testName, QImage &image, int mismatchCount )

‎tests/src/core/testqgsmapsettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void TestQgsMapSettings::testMapLayerListUtils()
198198
l = _qgis_findLayer( listRawSource, QStringLiteral( "z" ) );
199199
QCOMPARE( !l, true );
200200

201-
QList< QPointer<QgsMapLayer> > listQPointer = _qgis_listRawToQPointer( listRawSource );
201+
QgsWeakMapLayerPointerList listQPointer = _qgis_listRawToQPointer( listRawSource );
202202

203203
QCOMPARE( listQPointer.count(), 2 );
204204
QCOMPARE( listQPointer[0].data(), vlA );

0 commit comments

Comments
 (0)
Please sign in to comment.