Skip to content

Commit

Permalink
try disconnect/connect for destroyIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Apr 25, 2018
1 parent 43e905d commit 07caafe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/core/qgspointlocator.sip.in
Expand Up @@ -73,7 +73,7 @@ Configure extent - if not null, it will index only that area
.. versionadded:: 2.14
%End

void setRenderContext( const QgsRenderContext &context );
void setRenderContext( const QgsRenderContext *context );
%Docstring
Configure render context - if not null, it will use to index only visible feature

Expand Down
13 changes: 10 additions & 3 deletions src/core/qgspointlocator.cpp
Expand Up @@ -663,12 +663,19 @@ void QgsPointLocator::setExtent( const QgsRectangle *extent )
destroyIndex();
}

void QgsPointLocator::setRenderContext( const QgsRenderContext &context )
void QgsPointLocator::setRenderContext( const QgsRenderContext *context )
{
mContext = std::unique_ptr<QgsRenderContext>( new QgsRenderContext( context ) );
disconnect( mLayer, &QgsVectorLayer::styleChanged, this, &QgsPointLocator::destroyIndex );

connect( mLayer, &QgsVectorLayer::styleChanged, this, &QgsPointLocator::destroyIndex );
destroyIndex();
mContext.reset( nullptr );

if ( context )
{
mContext = std::unique_ptr<QgsRenderContext>( new QgsRenderContext( *context ) );
connect( mLayer, &QgsVectorLayer::styleChanged, this, &QgsPointLocator::destroyIndex );
}

}

bool QgsPointLocator::init( int maxFeaturesToIndex )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspointlocator.h
Expand Up @@ -99,7 +99,7 @@ class CORE_EXPORT QgsPointLocator : public QObject
* Configure render context - if not null, it will use to index only visible feature
* \since QGIS 3.2
*/
void setRenderContext( const QgsRenderContext &context );
void setRenderContext( const QgsRenderContext *context );

/**
* The type of a snap result or the filter type for a snap request.
Expand Down
5 changes: 4 additions & 1 deletion src/core/qgssnappingutils.cpp
Expand Up @@ -363,7 +363,10 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers
QgsPointLocator *loc = locatorForLayer( vl );

if ( !mEnableSnappingForInvisibleFeature )
loc->setRenderContext( QgsRenderContext::fromMapSettings( mMapSettings ) );
{
QgsRenderContext ctx = QgsRenderContext::fromMapSettings( mMapSettings );
loc->setRenderContext( &ctx );
}

if ( mStrategy == IndexExtent )
{
Expand Down

0 comments on commit 07caafe

Please sign in to comment.