Skip to content

Commit 402df03

Browse files
committed
ows data items: population of children already runs in a thread - don't use subthreads for each provider (fixes #12507)
1 parent ef62616 commit 402df03

File tree

5 files changed

+11
-41
lines changed

5 files changed

+11
-41
lines changed

src/app/qgisapp.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -7051,6 +7051,9 @@ void QgisApp::showMouseCoordinate( const QgsPoint & p )
70517051
{
70527052
if ( mMapCanvas->mapUnits() == QGis::Degrees )
70537053
{
7054+
if ( !mMapCanvas->mapSettings().destinationCrs().isValid() )
7055+
return;
7056+
70547057
QgsPoint geo = p;
70557058
if ( !mMapCanvas->mapSettings().destinationCrs().geographicFlag() )
70567059
{

src/core/qgsdataitem.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,14 @@ QVector<QgsDataItem*> QgsDataItem::createChildren()
350350
return QVector<QgsDataItem*>();
351351
}
352352

353-
void QgsDataItem::populate()
353+
void QgsDataItem::populate( bool foreground )
354354
{
355355
if ( state() == Populated || state() == Populating )
356356
return;
357357

358358
QgsDebugMsg( "mPath = " + mPath );
359359

360-
if ( capabilities2() & QgsDataItem::Fast )
360+
if ( capabilities2() & QgsDataItem::Fast || foreground )
361361
{
362362
populate( createChildren() );
363363
}
@@ -390,7 +390,7 @@ QVector<QgsDataItem*> QgsDataItem::runCreateChildren( QgsDataItem* item )
390390
QgsDebugMsg( "moveToThread child " + child->path() );
391391
child->moveToThread( QApplication::instance()->thread() ); // moves also children
392392
}
393-
QgsDebugMsg( "finished path = " + item->path() );
393+
QgsDebugMsg( QString( "finished path %1: %2 children" ).arg( item->path() ).arg( children.size() ) );
394394
return children;
395395
}
396396

src/core/qgsdataitem.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ class CORE_EXPORT QgsDataItem : public QObject
241241
virtual void deleteLater();
242242

243243
// Populate children using children vector created by createChildren()
244-
virtual void populate();
244+
// @param foreground run createChildren in foreground
245+
virtual void populate( bool foreground = false );
245246

246247
/** Remove children recursively and set as not populated. This is used when refreshing collapsed items. */
247248
virtual void depopulate();

src/providers/ows/qgsowsdataitems.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ QVector<QgsDataItem*> QgsOWSConnectionItem::createChildren()
6969
continue;
7070
}
7171

72-
item->populate();
72+
item->populate( true ); // populate in foreground - this is already run in a thread
7373

7474
layerCount += item->rowCount();
7575
if ( item->rowCount() > 0 )

src/providers/wms/qgswmsdataitems.cpp

+2-36
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@
2020
#include "qgswmscapabilities.h"
2121
#include "qgswmsconnection.h"
2222
#include "qgswmssourceselect.h"
23-
2423
#include "qgsnewhttpconnection.h"
25-
2624
#include "qgstilescalewidget.h"
2725

28-
#include "qgsapplication.h"
29-
3026
// ---------------------------------------------------------------------------
3127
QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path, QString uri )
3228
: QgsDataCollectionItem( parent, name, path )
@@ -46,19 +42,7 @@ QVector<QgsDataItem*> QgsWMSConnectionItem::createChildren()
4642

4743
QgsDataSourceURI uri;
4844
uri.setEncodedUri( mUri );
49-
#if 0
50-
if ( mPath.contains( "url=" ) )
51-
{
52-
encodedUri = mPath;
53-
uri.setEncodedUri( encodedUri );
54-
}
55-
else
56-
{
57-
QgsWMSConnection connection( mName );
58-
uri = connection.uri();
59-
encodedUri = uri.encodedUri();
60-
}
61-
#endif
45+
6246
QgsDebugMsg( "mUri = " + mUri );
6347

6448
QgsWmsSettings wmsSettings;
@@ -70,25 +54,6 @@ QVector<QgsDataItem*> QgsWMSConnectionItem::createChildren()
7054

7155
QgsWmsCapabilitiesDownload capDownload( wmsSettings.baseUrl(), wmsSettings.authorization() );
7256

73-
#if 0
74-
QWidget *mainWindow = 0;
75-
76-
QWidgetList topLevelWidgets = qApp->topLevelWidgets();
77-
for ( QWidgetList::iterator it = topLevelWidgets.begin(); it != topLevelWidgets.end(); ++it )
78-
{
79-
if (( *it )->objectName() == "QgisApp" )
80-
{
81-
mainWindow = *it;
82-
break;
83-
}
84-
}
85-
86-
if ( mainWindow )
87-
{
88-
connect( &capDownload, SIGNAL( statusChanged( QString ) ), mainWindow, SLOT( showStatusMessage( QString ) ) );
89-
}
90-
#endif
91-
9257
bool res = capDownload.downloadCapabilities();
9358

9459
if ( !res )
@@ -402,6 +367,7 @@ QWidget * QgsWMSRootItem::paramWidget()
402367
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) );
403368
return select;
404369
}
370+
405371
void QgsWMSRootItem::connectionsChanged()
406372
{
407373
refresh();

0 commit comments

Comments
 (0)