Skip to content

Commit b81fb0a

Browse files
author
jef
committed
fix #2639:
- use asynchronous WMS GetMap requests only when render caching is active - also cache WMS GetMap replies git-svn-id: http://svn.osgeo.org/qgis/trunk@13305 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 079deeb commit b81fb0a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/providers/wms/qgswmsprovider.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,20 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri )
9898
if ( smNAM )
9999
{
100100
QNetworkProxy proxy = smNAM->proxy();
101+
#if QT_VERSION >= 0x40500
101102
QgsDebugMsg( QString( "proxy host:%1:%2 type:%3 user:%4 password:%5 capabilities:%6" )
102103
.arg( proxy.hostName() ).arg( proxy.port() )
103104
.arg( proxy.type() )
104105
.arg( proxy.user() ).arg( proxy.password() )
105-
#if QT_VERSION >= 0x40500
106106
.arg( proxy.capabilities() )
107+
);
107108
#else
108-
.arg( 0 )
109-
#endif
109+
QgsDebugMsg( QString( "proxy host:%1:%2 type:%3 user:%4 password:%5" )
110+
.arg( proxy.hostName() ).arg( proxy.port() )
111+
.arg( proxy.type() )
112+
.arg( proxy.user() ).arg( proxy.password() )
110113
);
111-
114+
#endif
112115
}
113116
}
114117

@@ -433,6 +436,9 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
433436
cachedViewWidth = pixelWidth;
434437
cachedViewHeight = pixelHeight;
435438

439+
QSettings s;
440+
bool bkLayerCaching = s.value( "/qgis/enable_render_caching", false ).toBool();
441+
436442
if ( !mTiled )
437443
{
438444
// Calculate active layers that are also visible.
@@ -529,7 +535,9 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
529535
}
530536

531537
QgsDebugMsg( QString( "getmap: %1" ).arg( url ) );
532-
cacheReply = smNAM->get( QNetworkRequest( url ) );
538+
QNetworkRequest request( url );
539+
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
540+
cacheReply = smNAM->get( request );
533541
connect( cacheReply, SIGNAL( finished() ), this, SLOT( cacheReplyFinished() ) );
534542
connect( cacheReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( cacheReplyProgress( qint64, qint64 ) ) );
535543

@@ -538,7 +546,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
538546
QTime t;
539547
t.start();
540548

541-
while ( cacheReply && t.elapsed() < WMS_THRESHOLD )
549+
while ( cacheReply && ( !bkLayerCaching || t.elapsed() < WMS_THRESHOLD ) )
542550
{
543551
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents, WMS_THRESHOLD );
544552
}
@@ -663,7 +671,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
663671

664672
// draw everything that is retrieved within a second
665673
// and the rest asynchronously
666-
while ( !tileReplies.isEmpty() && t.elapsed() < WMS_THRESHOLD )
674+
while ( !tileReplies.isEmpty() && ( !bkLayerCaching || t.elapsed() < WMS_THRESHOLD ) )
667675
{
668676
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents, WMS_THRESHOLD );
669677
}

0 commit comments

Comments
 (0)