try disconnect/connect for destroyIndex

This commit is contained in:
Loïc Bartoletti 2018-04-25 17:05:14 +02:00
parent 43e905d7fc
commit 07caafe7c6
4 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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 )

View File

@ -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.

View File

@ -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 )
{