Skip to content
Permalink
Browse files

Avoid hang on WMS legends with missing graphics (fix #12234)

  • Loading branch information
nyalldawson committed Jul 9, 2015
1 parent 390d832 commit 4f29c58e4357fad505c82459e97c17449bf4891b
Showing with 17 additions and 0 deletions.
  1. +16 −0 src/providers/wms/qgswmsprovider.cpp
  2. +1 −0 src/providers/wms/qgswmsprovider.h
@@ -3041,6 +3041,7 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh, const
mLegendGraphicFetcher.reset( new QgsWmsLegendDownloadHandler( *QgsNetworkAccessManager::instance(), mSettings, url ) );
if ( ! mLegendGraphicFetcher ) return QImage();
connect( mLegendGraphicFetcher.data(), SIGNAL( finish( const QImage& ) ), this, SLOT( getLegendGraphicReplyFinished( const QImage& ) ) );
connect( mLegendGraphicFetcher.data(), SIGNAL( error( const QString& ) ), this, SLOT( getLegendGraphicReplyErrored( const QString& ) ) );
connect( mLegendGraphicFetcher.data(), SIGNAL( progress( qint64, qint64 ) ), this, SLOT( getLegendGraphicReplyProgress( qint64, qint64 ) ) );
mLegendGraphicFetcher->start( );

@@ -3119,6 +3120,21 @@ void QgsWmsProvider::getLegendGraphicReplyFinished( const QImage& img )
}
}

void QgsWmsProvider::getLegendGraphicReplyErrored( const QString& message )
{
QgsDebugMsg( QString( "get legend failed: %1" ).arg( message ) );

QObject* reply = sender();

if ( reply == mLegendGraphicFetcher.data() )
{
QEventLoop *loop = qobject_cast< QEventLoop *>( reply->property( "eventLoop" ).value< QObject *>() );
if ( loop )
QMetaObject::invokeMethod( loop, "quit", Qt::QueuedConnection );
mLegendGraphicFetcher.reset();
}
}

void QgsWmsProvider::getLegendGraphicReplyProgress( qint64 bytesReceived, qint64 bytesTotal )
{
QString msg = tr( "%1 of %2 bytes of GetLegendGraphic downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) );
@@ -367,6 +367,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
private slots:
void identifyReplyFinished();
void getLegendGraphicReplyFinished( const QImage& );
void getLegendGraphicReplyErrored( const QString& message );
void getLegendGraphicReplyProgress( qint64, qint64 );

private:

0 comments on commit 4f29c58

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