@@ -3041,6 +3041,7 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh, const
3041
3041
mLegendGraphicFetcher .reset ( new QgsWmsLegendDownloadHandler ( *QgsNetworkAccessManager::instance (), mSettings , url ) );
3042
3042
if ( ! mLegendGraphicFetcher ) return QImage ();
3043
3043
connect ( mLegendGraphicFetcher .data (), SIGNAL ( finish ( const QImage& ) ), this , SLOT ( getLegendGraphicReplyFinished ( const QImage& ) ) );
3044
+ connect ( mLegendGraphicFetcher .data (), SIGNAL ( error ( const QString& ) ), this , SLOT ( getLegendGraphicReplyErrored ( const QString& ) ) );
3044
3045
connect ( mLegendGraphicFetcher .data (), SIGNAL ( progress ( qint64, qint64 ) ), this , SLOT ( getLegendGraphicReplyProgress ( qint64, qint64 ) ) );
3045
3046
mLegendGraphicFetcher ->start ( );
3046
3047
@@ -3119,6 +3120,21 @@ void QgsWmsProvider::getLegendGraphicReplyFinished( const QImage& img )
3119
3120
}
3120
3121
}
3121
3122
3123
+ void QgsWmsProvider::getLegendGraphicReplyErrored ( const QString& message )
3124
+ {
3125
+ QgsDebugMsg ( QString ( " get legend failed: %1" ).arg ( message ) );
3126
+
3127
+ QObject* reply = sender ();
3128
+
3129
+ if ( reply == mLegendGraphicFetcher .data () )
3130
+ {
3131
+ QEventLoop *loop = qobject_cast< QEventLoop *>( reply->property ( " eventLoop" ).value < QObject *>() );
3132
+ if ( loop )
3133
+ QMetaObject::invokeMethod ( loop, " quit" , Qt::QueuedConnection );
3134
+ mLegendGraphicFetcher .reset ();
3135
+ }
3136
+ }
3137
+
3122
3138
void QgsWmsProvider::getLegendGraphicReplyProgress ( qint64 bytesReceived, qint64 bytesTotal )
3123
3139
{
3124
3140
QString msg = tr ( " %1 of %2 bytes of GetLegendGraphic downloaded." ).arg ( bytesReceived ).arg ( bytesTotal < 0 ? QString ( " unknown number of" ) : QString::number ( bytesTotal ) );
0 commit comments