Skip to content

Commit

Permalink
[bugfix] Fix crash in virtual layers dlg when adding
Browse files Browse the repository at this point in the history
Fixes #17724 Crash on clicking ADD in Virtual Layer
dialogue without defining a layer

A proper implementation should handle the Add button
state when a virtual layer definition is available.
  • Loading branch information
elpaso committed Dec 21, 2017
1 parent 9fe8729 commit 385d0ef
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/providers/virtual/qgsvirtuallayersourceselect.cpp
Expand Up @@ -374,13 +374,18 @@ void QgsVirtualLayerSourceSelect::addButtonClicked()
}
}
}
if ( replace )
{
emit replaceVectorLayer( id, def.toString(), layerName, QStringLiteral( "virtual" ) );
}
else
// This check is to prevent a crash, a proper implementation should handle
// the Add button state when a virtual layer definition is available
if ( ! def.toString().isEmpty() )
{
emit addVectorLayer( def.toString(), layerName );
if ( replace )
{
emit replaceVectorLayer( id, def.toString(), layerName, QStringLiteral( "virtual" ) );
}
else
{
emit addVectorLayer( def.toString(), layerName );
}
}
if ( widgetMode() == QgsProviderRegistry::WidgetMode::None )
{
Expand Down

0 comments on commit 385d0ef

Please sign in to comment.