Skip to content
Permalink
Browse files

Avoid issues if active layer changes

  • Loading branch information
nyalldawson committed Jun 1, 2017
1 parent 787769a commit 19ca0e00a7572577bfc9a0d64ba7958c37413cbf
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/app/locator/qgsinbuiltlocatorfilters.cpp
@@ -237,21 +237,23 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c

result.description = dispExpression.evaluate( &context ).toString();

result.userData = f.id();
result.userData = QVariantList() << f.id() << layer->id();
result.icon = QgsMapLayerModel::iconForLayer( layer );
result.score = static_cast< double >( string.length() ) / result.displayString.size();
emit resultFetched( result );

found++;
if ( found >= 30 )
return;
break;
}
}

void QgsActiveLayerFeaturesLocatorFilter::triggerResult( const QgsLocatorResult &result )
{
QgsFeatureId id = result.userData.toLongLong();
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( QgisApp::instance()->activeLayer() );
QVariantList dataList = result.userData.toList();
QgsFeatureId id = dataList.at( 0 ).toLongLong();
QString layerId = dataList.at( 1 ).toString();
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( QgsProject::instance()->mapLayer( layerId ) );
if ( !layer )
return;

0 comments on commit 19ca0e0

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