Skip to content

Commit b9b8513

Browse files
committed
Check only what's necessary to see if a layer will be labeled
- Don't load all settings from QgsPalLayerSettings::readFromLayer
1 parent b9d0bc8 commit b9b8513

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/core/qgspallabeling.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -3000,9 +3000,12 @@ QgsPalLabeling::~QgsPalLabeling()
30003000

30013001
bool QgsPalLabeling::willUseLayer( QgsVectorLayer* layer )
30023002
{
3003-
QgsPalLayerSettings lyrTmp;
3004-
lyrTmp.readFromLayer( layer );
3005-
return lyrTmp.enabled;
3003+
// don't do QgsPalLayerSettings::readFromLayer( layer ) if not needed
3004+
bool enabled = false;
3005+
if ( layer->customProperty( "labeling" ).toString() == QString( "pal" ) )
3006+
enabled = layer->customProperty( "labeling/enabled", QVariant( false ) ).toBool();
3007+
3008+
return enabled;
30063009
}
30073010

30083011
void QgsPalLabeling::clearActiveLayers()
@@ -3031,14 +3034,20 @@ void QgsPalLabeling::clearActiveLayer( QgsVectorLayer* layer )
30313034

30323035
int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices, QgsRenderContext& ctx )
30333036
{
3034-
QgsDebugMsgLevel( "PREPARE LAYER " + layer->id(), 4 );
30353037
Q_ASSERT( mMapRenderer != NULL );
30363038

3039+
if ( !willUseLayer( layer ) )
3040+
{
3041+
return 0;
3042+
}
3043+
3044+
QgsDebugMsgLevel( "PREPARE LAYER " + layer->id(), 4 );
3045+
30373046
// start with a temporary settings class, find out labeling info
30383047
QgsPalLayerSettings lyrTmp;
30393048
lyrTmp.readFromLayer( layer );
30403049

3041-
if ( !lyrTmp.enabled || lyrTmp.fieldName.isEmpty() )
3050+
if ( lyrTmp.fieldName.isEmpty() )
30423051
{
30433052
return 0;
30443053
}

0 commit comments

Comments
 (0)