Skip to content
Permalink
Browse files

Ensure browser model is initialized when used by QgsDataSourceSelectD…

…ialog
  • Loading branch information
github-actions authored and nyalldawson committed Jan 21, 2020
1 parent 7204de2 commit e8a6c2bfeee2a14365002297c517421dd5ca39a8
Showing with 7 additions and 14 deletions.
  1. +6 −12 src/gui/qgsdatasourceselectdialog.cpp
  2. +1 −2 src/gui/qgsdatasourceselectdialog.h
@@ -35,21 +35,20 @@ QgsDataSourceSelectDialog::QgsDataSourceSelectDialog(
{
if ( ! browserModel )
{
mBrowserModel = qgis::make_unique<QgsBrowserGuiModel>();
mBrowserModel = new QgsBrowserGuiModel( this );
mBrowserModel->initialize();
mOwnModel = true;
}
else
{
mBrowserModel.reset( browserModel );
mOwnModel = false;
mBrowserModel = browserModel;
mBrowserModel->initialize();
}

setupUi( this );
setWindowTitle( tr( "Select a Data Source" ) );
QgsGui::enableAutoGeometryRestore( this );

mBrowserProxyModel.setBrowserModel( mBrowserModel.get() );
mBrowserProxyModel.setBrowserModel( mBrowserModel );
mBrowserTreeView->setHeaderHidden( true );

if ( setFilterByLayerType )
@@ -63,7 +62,7 @@ QgsDataSourceSelectDialog::QgsDataSourceSelectDialog(
buttonBox->button( QDialogButtonBox::StandardButton::Ok )->setEnabled( false );
}

mBrowserTreeView->setBrowserModel( mBrowserModel.get() );
mBrowserTreeView->setBrowserModel( mBrowserModel );

mWidgetFilter->hide();
mLeFilter->setPlaceholderText( tr( "Type here to filter visible items…" ) );
@@ -116,12 +115,7 @@ QgsDataSourceSelectDialog::QgsDataSourceSelectDialog(
}
}

QgsDataSourceSelectDialog::~QgsDataSourceSelectDialog()
{
if ( ! mOwnModel )
mBrowserModel.release();
}

QgsDataSourceSelectDialog::~QgsDataSourceSelectDialog() = default;

void QgsDataSourceSelectDialog::showEvent( QShowEvent *e )
{
@@ -106,8 +106,7 @@ class GUI_EXPORT QgsDataSourceSelectDialog: public QDialog, private Ui::QgsDataS
void refreshModel( const QModelIndex &index );

QgsBrowserProxyModel mBrowserProxyModel;
std::unique_ptr<QgsBrowserGuiModel> mBrowserModel;
bool mOwnModel = true;
QgsBrowserGuiModel *mBrowserModel = nullptr;
QgsMimeDataUtils::Uri mUri;
QLabel *mDescriptionLabel = nullptr;

0 comments on commit e8a6c2b

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