Skip to content
Permalink
Browse files
Catch SQL filter dialog connection errors (never seen in the wild)
  • Loading branch information
elpaso committed Jul 6, 2021
1 parent 233a809 commit f1a5014121f43981c365b9fa3f86f91521227eef
Showing with 13 additions and 6 deletions.
  1. +1 −1 python/gui/auto_generated/qgsqueryresultwidget.sip.in
  2. +12 −5 src/gui/qgsqueryresultwidget.cpp
@@ -24,7 +24,7 @@ Query execution and result fetching can be interrupted by pressing the "Stop" pu

the ownership of the connection is transferred to the widget.

.. versionadded:: 3.20
.. versionadded:: 3.22
%End

%TypeHeaderCode
@@ -22,7 +22,7 @@


QgsQueryResultWidget::QgsQueryResultWidget( QWidget *parent, QgsAbstractDatabaseProviderConnection *connection )
: QWidget::QWidget( parent )
: QWidget( parent )
{
setupUi( this );

@@ -50,11 +50,18 @@ QgsQueryResultWidget::QgsQueryResultWidget( QWidget *parent, QgsAbstractDatabase
{
if ( mConnection )
{
std::unique_ptr<QgsVectorLayer> vlayer { mConnection->createSqlVectorLayer( sqlVectorLayerOptions() ) };
QgsQueryBuilder builder{ vlayer.get() };
if ( builder.exec() == QDialog::Accepted )
try
{
std::unique_ptr<QgsVectorLayer> vlayer { mConnection->createSqlVectorLayer( sqlVectorLayerOptions() ) };
QgsQueryBuilder builder{ vlayer.get() };
if ( builder.exec() == QDialog::Accepted )
{
mFilterLineEdit->setText( builder.sql() );
}
}
catch ( const QgsProviderConnectionException &ex )
{
mFilterLineEdit->setText( builder.sql() );
mMessageBar->pushCritical( tr( "Error opening filter dialog" ), tr( "There was an error while preparing SQL filter dialog: %1." ).arg( ex.what() ) );
}
}
} );

0 comments on commit f1a5014

Please sign in to comment.