Skip to content

Commit

Permalink
Check only what's necessary to see if a layer will be labeled
Browse files Browse the repository at this point in the history
- Don't load all settings from QgsPalLayerSettings::readFromLayer
  • Loading branch information
dakcarto committed Jun 10, 2013
1 parent b9d0bc8 commit b9b8513
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/core/qgspallabeling.cpp
Expand Up @@ -3000,9 +3000,12 @@ QgsPalLabeling::~QgsPalLabeling()

bool QgsPalLabeling::willUseLayer( QgsVectorLayer* layer )
{
QgsPalLayerSettings lyrTmp;
lyrTmp.readFromLayer( layer );
return lyrTmp.enabled;
// don't do QgsPalLayerSettings::readFromLayer( layer ) if not needed
bool enabled = false;
if ( layer->customProperty( "labeling" ).toString() == QString( "pal" ) )
enabled = layer->customProperty( "labeling/enabled", QVariant( false ) ).toBool();

return enabled;
}

void QgsPalLabeling::clearActiveLayers()
Expand Down Expand Up @@ -3031,14 +3034,20 @@ void QgsPalLabeling::clearActiveLayer( QgsVectorLayer* layer )

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

if ( !willUseLayer( layer ) )
{
return 0;
}

QgsDebugMsgLevel( "PREPARE LAYER " + layer->id(), 4 );

// start with a temporary settings class, find out labeling info
QgsPalLayerSettings lyrTmp;
lyrTmp.readFromLayer( layer );

if ( !lyrTmp.enabled || lyrTmp.fieldName.isEmpty() )
if ( lyrTmp.fieldName.isEmpty() )
{
return 0;
}
Expand Down

0 comments on commit b9b8513

Please sign in to comment.