Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock when calling datasource manager dialog refresh #60495

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ void QgisApp::dataSourceManager( const QString &pageName, const QString &layerUr
if ( !mDataSourceManagerDialog )
{
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mBrowserModel, this, mapCanvas() );
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh );
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh, Qt::ConnectionType::QueuedConnection );
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::connectionsChanged, this, &QgisApp::connectionsChanged );


Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsdatasourcemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void QgsDataSourceManagerDialog::makeConnections( QgsAbstractDataSourceWidget *d
connect( dlg, &QgsAbstractDataSourceWidget::replaceVectorLayer, this, &QgsDataSourceManagerDialog::replaceSelectedVectorLayer );
// Common
connect( dlg, &QgsAbstractDataSourceWidget::connectionsChanged, this, &QgsDataSourceManagerDialog::connectionsChanged );
connect( this, &QgsDataSourceManagerDialog::providerDialogsRefreshRequested, dlg, &QgsAbstractDataSourceWidget::refresh );
connect( this, &QgsDataSourceManagerDialog::providerDialogsRefreshRequested, dlg, &QgsAbstractDataSourceWidget::refresh, Qt::ConnectionType::QueuedConnection );

// Message
connect( dlg, &QgsAbstractDataSourceWidget::pushMessage, this, [=]( const QString &title, const QString &message, const Qgis::MessageLevel level ) {
Expand Down
27 changes: 17 additions & 10 deletions src/gui/qgslayermetadatasearchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ QgsLayerMetadataSearchWidget::QgsLayerMetadataSearchWidget( QWidget *parent, Qt:
if ( progress == 100 )
{
mIsLoading = false;
mReloadRequired = false;
mProgressBar->hide();
updateLoadBtn();
}
Expand All @@ -90,15 +91,16 @@ QgsLayerMetadataSearchWidget::QgsLayerMetadataSearchWidget( QWidget *parent, Qt:
connect( mAbortPushButton, &QPushButton::clicked, mSourceModel, [=]( bool ) {
if ( !mIsLoading )
{
mIsLoading = true;
mProgressBar->show();
mSourceModel->reloadAsync();
mReloadRequired = true;
refresh();
}
else
{
mProgressBar->hide();
mSourceModel->cancel();
mIsLoading = false;
mReloadRequired = false;
}
updateLoadBtn();
} );
Expand Down Expand Up @@ -181,8 +183,9 @@ void QgsLayerMetadataSearchWidget::updateExtentFilter( int index )

void QgsLayerMetadataSearchWidget::refresh()
{
mIsLoading = true;
mSourceModel->reloadAsync();
// Lazy reload
mReloadRequired = true;
refreshInternal();
}

void QgsLayerMetadataSearchWidget::addButtonClicked()
Expand Down Expand Up @@ -258,15 +261,19 @@ void QgsLayerMetadataSearchWidget::showEvent( QShowEvent *event )
{
QgsAbstractDataSourceWidget::showEvent( event );
mSearchFilterLineEdit->setText( mProxyModel->filterString() );
// The first show event triggers the metadata loading
if ( !mIsInitialized )
{
refresh();
mIsInitialized = true;
}
refreshInternal();
}

void QgsLayerMetadataSearchWidget::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#the-layer-metadata-search-panel" ) );
}

void QgsLayerMetadataSearchWidget::refreshInternal()
{
if ( mReloadRequired && isVisible() )
{
mIsLoading = true;
mSourceModel->reloadAsync();
}
}
4 changes: 3 additions & 1 deletion src/gui/qgslayermetadatasearchwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ class GUI_EXPORT QgsLayerMetadataSearchWidget : public QgsAbstractDataSourceWidg
private:
QgsLayerMetadataResultsProxyModel *mProxyModel = nullptr;
bool mIsLoading = false;
bool mIsInitialized = false;
bool mReloadRequired = true;
QgsLayerMetadataResultsModel *mSourceModel = nullptr;

void refreshInternal();

// QWidget interface
protected:
void showEvent( QShowEvent *event ) override;
Expand Down
Loading