Skip to content
Permalink
Browse files

[bugfix] Do not crash when testing empty virtual layers

Fixes #17489

Backported from master
  • Loading branch information
elpaso committed Nov 20, 2017
1 parent 33e939c commit ac109e430261628c0dd37437f18e056fced12f86
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/providers/virtual/qgsvirtuallayersourceselect.cpp
@@ -229,15 +229,20 @@ QgsVirtualLayerDefinition QgsVirtualLayerSourceSelect::getVirtualLayerDef()
void QgsVirtualLayerSourceSelect::onTestQuery()
{
QgsVirtualLayerDefinition def = getVirtualLayerDef();

QScopedPointer<QgsVectorLayer> vl( new QgsVectorLayer( def.toString(), "test", "virtual" ) );
if ( vl->isValid() )
{
QMessageBox::information( nullptr, tr( "Virtual layer test" ), tr( "No error" ) );
}
else
// If the definition is empty just do nothing.
// TODO: a validation function that can enable/disable the test button
// according to the validity of the active layer definition
if ( ! def.toString().isEmpty() )
{
QMessageBox::critical( nullptr, tr( "Virtual layer test" ), vl->dataProvider()->error().summary() );
QScopedPointer<QgsVectorLayer> vl( new QgsVectorLayer( def.toString(), "test", "virtual" ) );
if ( vl->isValid() )
{
QMessageBox::information( nullptr, tr( "Virtual layer test" ), tr( "No error" ) );
}
else
{
QMessageBox::critical( nullptr, tr( "Virtual layer test" ), vl->dataProvider()->error().summary() );
}
}
}

0 comments on commit ac109e4

Please sign in to comment.
You can’t perform that action at this time.