File tree 1 file changed +13
-8
lines changed
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -229,15 +229,20 @@ QgsVirtualLayerDefinition QgsVirtualLayerSourceSelect::getVirtualLayerDef()
229
229
void QgsVirtualLayerSourceSelect::onTestQuery ()
230
230
{
231
231
QgsVirtualLayerDefinition def = getVirtualLayerDef ();
232
-
233
- QScopedPointer<QgsVectorLayer> vl ( new QgsVectorLayer ( def.toString (), " test" , " virtual" ) );
234
- if ( vl->isValid () )
235
- {
236
- QMessageBox::information ( nullptr , tr ( " Virtual layer test" ), tr ( " No error" ) );
237
- }
238
- else
232
+ // If the definition is empty just do nothing.
233
+ // TODO: a validation function that can enable/disable the test button
234
+ // according to the validity of the active layer definition
235
+ if ( ! def.toString ().isEmpty () )
239
236
{
240
- QMessageBox::critical ( nullptr , tr ( " Virtual layer test" ), vl->dataProvider ()->error ().summary () );
237
+ QScopedPointer<QgsVectorLayer> vl ( new QgsVectorLayer ( def.toString (), " test" , " virtual" ) );
238
+ if ( vl->isValid () )
239
+ {
240
+ QMessageBox::information ( nullptr , tr ( " Virtual layer test" ), tr ( " No error" ) );
241
+ }
242
+ else
243
+ {
244
+ QMessageBox::critical ( nullptr , tr ( " Virtual layer test" ), vl->dataProvider ()->error ().summary () );
245
+ }
241
246
}
242
247
}
243
248
You can’t perform that action at this time.
0 commit comments