Skip to content
Permalink
Browse files
Fix system tables disappear from dialog after task runs
  • Loading branch information
nyalldawson committed Aug 26, 2021
1 parent 37dc64f commit 136faab91fe1f21c7efe2208876330ff2c64db0d
@@ -35,7 +35,7 @@ possible, regardless of how expensive this may be.
%End
public:

QgsProviderSublayerTask( const QString &uri );
QgsProviderSublayerTask( const QString &uri, bool includeSystemTables );
%Docstring
Constructor for QgsProviderSublayerTask, which retrieves sublayer details for the
specified ``uri``.
@@ -163,7 +163,7 @@ QgsProviderSublayersDialog::QgsProviderSublayersDialog( const QString &uri, cons
if ( QgsProviderUtils::sublayerDetailsAreIncomplete( initialDetails ) )
{
// initial details are incomplete, so fire up a task in the background to fully populate the model...
mTask = new QgsProviderSublayerTask( uri );
mTask = new QgsProviderSublayerTask( uri, true );
connect( mTask.data(), &QgsProviderSublayerTask::taskCompleted, this, [ = ]
{
QList< QgsProviderSublayerDetails > res = mTask->results();
@@ -21,9 +21,10 @@
#include "qgsprovidersublayerdetails.h"
#include "qgsreadwritelocker.h"

QgsProviderSublayerTask::QgsProviderSublayerTask( const QString &uri )
QgsProviderSublayerTask::QgsProviderSublayerTask( const QString &uri, bool includeSystemTables )
: QgsTask( tr( "Retrieving layers" ), QgsTask::CanCancel | QgsTask::CancelWithoutPrompt )
, mUri( uri )
, mIncludeSystemTables( includeSystemTables )
{
}

@@ -39,7 +40,11 @@ bool QgsProviderSublayerTask::run()
{
mFeedback = std::make_unique< QgsFeedback >();

const QList<QgsProviderSublayerDetails> res = QgsProviderRegistry::instance()->querySublayers( mUri, Qgis::SublayerQueryFlag::ResolveGeometryType | Qgis::SublayerQueryFlag::CountFeatures, mFeedback.get() );
Qgis::SublayerQueryFlags flags = Qgis::SublayerQueryFlag::ResolveGeometryType | Qgis::SublayerQueryFlag::CountFeatures;
if ( mIncludeSystemTables )
flags |= Qgis::SublayerQueryFlag::IncludeSystemTables;

const QList<QgsProviderSublayerDetails> res = QgsProviderRegistry::instance()->querySublayers( mUri, flags, mFeedback.get() );

const QgsReadWriteLocker locker( mLock, QgsReadWriteLocker::Write );
mResults = res;
@@ -53,7 +53,7 @@ class CORE_EXPORT QgsProviderSublayerTask : public QgsTask
* Constructor for QgsProviderSublayerTask, which retrieves sublayer details for the
* specified \a uri.
*/
QgsProviderSublayerTask( const QString &uri );
QgsProviderSublayerTask( const QString &uri, bool includeSystemTables );

~QgsProviderSublayerTask() override;

@@ -72,6 +72,8 @@ class CORE_EXPORT QgsProviderSublayerTask : public QgsTask

QString mUri;

bool mIncludeSystemTables = false;

std::unique_ptr< QgsFeedback > mFeedback;

QList<QgsProviderSublayerDetails> mResults;

0 comments on commit 136faab

Please sign in to comment.