Skip to content

Commit

Permalink
Avoid issues if active layer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 1, 2017
1 parent 787769a commit 19ca0e0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/app/locator/qgsinbuiltlocatorfilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 19ca0e0

Please sign in to comment.