Skip to content
Permalink
Browse files

vector layer: fix lazy extent calculation (fixes #9608; introduced in 5…

  • Loading branch information
jef-n committed Feb 20, 2014
1 parent 55cb04c commit a1ada3c54ceb9c4c2bf30b4d7afb2e2c70153fb3
Showing with 20 additions and 14 deletions.
  1. +19 −14 src/core/qgsvectorlayer.cpp
  2. +1 −0 src/core/qgsvectorlayer.h
@@ -136,6 +136,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
, mDiagramRenderer( 0 )
, mDiagramLayerSettings( 0 )
, mValidExtent( false )
, mLazyExtent( true )
, mSymbolFeatureCounted( false )
, mCurrentRendererContext( 0 )

@@ -1179,15 +1180,30 @@ void QgsVectorLayer::setExtent( const QgsRectangle &r )

QgsRectangle QgsVectorLayer::extent()
{
if ( mValidExtent )
return QgsMapLayer::extent();

QgsRectangle rect;
rect.setMinimal();

if ( !hasGeometryType() )
return rect;

if ( !mValidExtent && mLazyExtent && mDataProvider )
{
// get the extent
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QString s = mbr.toString();

QgsDebugMsg( "Extent of layer: " + s );
// store the extent
setExtent( mbr );

mLazyExtent = false;
}

if( mValidExtent )
return QgsMapLayer::extent();

if ( !mDataProvider )
{
QgsDebugMsg( "invoked with null mDataProvider" );
@@ -1704,17 +1720,6 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
// TODO: Check if the provider has the capability to send fullExtentCalculated
connect( mDataProvider, SIGNAL( fullExtentCalculated() ), this, SLOT( updateExtents() ) );

#if 0 // allow lazy calculation of extents and give the creator of the vector layer a chance to 'manually' setExtent
// get the extent
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QString s = mbr.toString();
QgsDebugMsg( "Extent of layer: " + s );
// store the extent
setExtent( mbr );
#endif

// get and store the feature type
mWkbType = mDataProvider->geometryType();

@@ -1756,6 +1756,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
QgsDiagramLayerSettings *mDiagramLayerSettings;

bool mValidExtent;
bool mLazyExtent;

// Features in renderer classes counted
bool mSymbolFeatureCounted;

0 comments on commit a1ada3c

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