mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[bugfix] Do not crash when testing empty virtual layers
Fixes #17489 Require backporting
This commit is contained in:
parent
e9ce901adc
commit
4272f5d825
@ -199,15 +199,20 @@ QgsVirtualLayerDefinition QgsVirtualLayerSourceSelect::getVirtualLayerDef()
|
||||
void QgsVirtualLayerSourceSelect::onTestQuery()
|
||||
{
|
||||
QgsVirtualLayerDefinition def = getVirtualLayerDef();
|
||||
|
||||
std::unique_ptr<QgsVectorLayer> vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ) ) );
|
||||
if ( vl->isValid() )
|
||||
// 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::information( nullptr, tr( "Virtual layer test" ), tr( "No error" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical( nullptr, tr( "Virtual layer test" ), vl->dataProvider()->error().summary() );
|
||||
std::unique_ptr<QgsVectorLayer> vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user