Skip to content

Commit 07caafe

Browse files
committedApr 25, 2018
try disconnect/connect for destroyIndex
1 parent 43e905d commit 07caafe

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed
 

‎python/core/qgspointlocator.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Configure extent - if not null, it will index only that area
7373
.. versionadded:: 2.14
7474
%End
7575

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

‎src/core/qgspointlocator.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,19 @@ void QgsPointLocator::setExtent( const QgsRectangle *extent )
663663
destroyIndex();
664664
}
665665

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

670-
connect( mLayer, &QgsVectorLayer::styleChanged, this, &QgsPointLocator::destroyIndex );
671670
destroyIndex();
671+
mContext.reset( nullptr );
672+
673+
if ( context )
674+
{
675+
mContext = std::unique_ptr<QgsRenderContext>( new QgsRenderContext( *context ) );
676+
connect( mLayer, &QgsVectorLayer::styleChanged, this, &QgsPointLocator::destroyIndex );
677+
}
678+
672679
}
673680

674681
bool QgsPointLocator::init( int maxFeaturesToIndex )

‎src/core/qgspointlocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CORE_EXPORT QgsPointLocator : public QObject
9999
* Configure render context - if not null, it will use to index only visible feature
100100
* \since QGIS 3.2
101101
*/
102-
void setRenderContext( const QgsRenderContext &context );
102+
void setRenderContext( const QgsRenderContext *context );
103103

104104
/**
105105
* The type of a snap result or the filter type for a snap request.

‎src/core/qgssnappingutils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,10 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers
363363
QgsPointLocator *loc = locatorForLayer( vl );
364364

365365
if ( !mEnableSnappingForInvisibleFeature )
366-
loc->setRenderContext( QgsRenderContext::fromMapSettings( mMapSettings ) );
366+
{
367+
QgsRenderContext ctx = QgsRenderContext::fromMapSettings( mMapSettings );
368+
loc->setRenderContext( &ctx );
369+
}
367370

368371
if ( mStrategy == IndexExtent )
369372
{

0 commit comments

Comments
 (0)
Please sign in to comment.