Skip to content

Commit

Permalink
Followup 01b4eeb: Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 17, 2017
1 parent cb1f98f commit 8bfbe19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/providers/virtual/qgsvirtuallayersourceselect.cpp
Expand Up @@ -249,8 +249,8 @@ void QgsVirtualLayerSourceSelect::updateLayersList()
QgsLayerTreeModel *model = qobject_cast<QgsLayerTreeModel *>( mTreeView->model() );
Q_FOREACH ( QgsLayerTreeLayer *layer, model->rootGroup()->findLayers() )
{
Q_ASSERT( layer->layer() );
if ( layer->layer()->type() == QgsMapLayer::VectorLayer && static_cast<QgsVectorLayer *>( layer->layer() )->providerType() == QLatin1String( "virtual" ) )
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer->layer() );
if ( vl && vl->providerType() == QLatin1String( "virtual" ) )
{
// store layer's id as user data
mLayerNameCombo->addItem( layer->layer()->name(), layer->layer()->id() );
Expand Down

2 comments on commit 8bfbe19

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on 8bfbe19 Jun 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elpaso This replaces a previous commit from you (01b4eeb)
I assume you wanted to fix the crash and not assessing in detail why layer->layer() can be a nullptr and enforce that this never happens, right?
This randomly crashes for me once in a while when reloading projects.

@elpaso
Copy link
Contributor

@elpaso elpaso commented on 8bfbe19 Jun 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn yes, I've ran into that bug while working on the new layers dialog, my first attempt was to add a check for layer() like you did (well, almost like you did: my check was on the uncasted layer() ) , but after adding Qt::QueuedConnection I was not able to reproduce the issue anymore and I though that it was solved, apparently I was mistaken, thanks for fixing it.

Please sign in to comment.