Skip to content
Permalink
Browse files
Fix crash when connection is invalid (nullptr)
  • Loading branch information
elpaso committed Jul 6, 2021
1 parent 5d5e828 commit ebfed52cf63d3c96a3843f0ca7911fd10b86028f
Showing with 23 additions and 20 deletions.
  1. +23 −20 src/gui/qgsqueryresultwidget.cpp
@@ -64,26 +64,6 @@ QgsQueryResultWidget::QgsQueryResultWidget( QWidget *parent, QgsAbstractDatabase
mStatusLabel->hide();
mSqlErrorText->hide();

// Configure the load layer interface
if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::PrimaryKeys ) )
{
mPkColumnsCheckBox->hide();
mPkColumnsComboBox->hide();
}

if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::GeometryColumn ) )
{
mGeometryColumnCheckBox->hide();
mGeometryColumnComboBox->hide();
}

if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::Filters ) )
{
mFilterLabel->hide();
mFilterToolButton->hide();
mFilterLineEdit->hide();
}

mLoadAsNewLayerGroupBox->setCollapsed( true );
setConnection( connection );
}
@@ -315,7 +295,30 @@ void QgsQueryResultWidget::setConnection( QgsAbstractDatabaseProviderConnection

if ( connection )
{

// Configure the load layer interface
if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::PrimaryKeys ) )
{
mPkColumnsCheckBox->hide();
mPkColumnsComboBox->hide();
}

if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::GeometryColumn ) )
{
mGeometryColumnCheckBox->hide();
mGeometryColumnComboBox->hide();
}

if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::Filters ) )
{
mFilterLabel->hide();
mFilterToolButton->hide();
mFilterLineEdit->hide();
}

mSqlEditor->setFieldNames( QStringList( ) );
// Add provider specific APIs
// TODO mSqlEditor->lexer()->apis()
mSqlErrorText->setFieldNames( QStringList( ) );
mApiFetcher = new QgsConnectionsApiFetcher( connection );
mApiFetcher->moveToThread( &mWorkerThread );

0 comments on commit ebfed52

Please sign in to comment.