Skip to content

Commit 02152ac

Browse files
authored
Merge pull request #5936 from elpaso/bugfix-17724-virtuallayer-crash
[bugfix] Fix crash in virtual layers dlg when adding
2 parents 224dcd0 + 385d0ef commit 02152ac

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/providers/virtual/qgsvirtuallayersourceselect.cpp

+11-6
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)