Skip to content

Commit 385d0ef

Browse files
committedDec 21, 2017
[bugfix] Fix crash in virtual layers dlg when adding
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.
1 parent 9fe8729 commit 385d0ef

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed
 

‎src/providers/virtual/qgsvirtuallayersourceselect.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,18 @@ void QgsVirtualLayerSourceSelect::addButtonClicked()
374374
}
375375
}
376376
}
377-
if ( replace )
378-
{
379-
emit replaceVectorLayer( id, def.toString(), layerName, QStringLiteral( "virtual" ) );
380-
}
381-
else
377+
// This check is to prevent a crash, a proper implementation should handle
378+
// the Add button state when a virtual layer definition is available
379+
if ( ! def.toString().isEmpty() )
382380
{
383-
emit addVectorLayer( def.toString(), layerName );
381+
if ( replace )
382+
{
383+
emit replaceVectorLayer( id, def.toString(), layerName, QStringLiteral( "virtual" ) );
384+
}
385+
else
386+
{
387+
emit addVectorLayer( def.toString(), layerName );
388+
}
384389
}
385390
if ( widgetMode() == QgsProviderRegistry::WidgetMode::None )
386391
{

0 commit comments

Comments
 (0)
Please sign in to comment.