@@ -2367,7 +2367,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
23672367 connect ( mIdentifyReply , SIGNAL ( finished () ), this , SLOT ( identifyReplyFinished () ) );
23682368
23692369 QEventLoop loop;
2370- connect ( mIdentifyReply , SIGNAL ( finished () ), &loop, SLOT ( quit ( ) ) );
2370+ mIdentifyReply -> setProperty ( " eventLoop " , QVariant::fromValue ( qobject_cast<QObject *>( &loop ) ) );
23712371 loop.exec ( QEventLoop::ExcludeUserInputEvents );
23722372
23732373 if ( mIdentifyResultBodies .size () == 0 ) // no result
@@ -2767,9 +2767,12 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
27672767
27682768void QgsWmsProvider::identifyReplyFinished ()
27692769{
2770+ QgsDebugMsg ( " Entered." );
27702771 mIdentifyResultHeaders .clear ();
27712772 mIdentifyResultBodies .clear ();
27722773
2774+ QEventLoop *loop = qobject_cast< QEventLoop *>( sender ()->property ( " eventLoop" ).value < QObject *>() );
2775+
27732776 if ( mIdentifyReply ->error () == QNetworkReply::NoError )
27742777 {
27752778 QVariant redirect = mIdentifyReply ->attribute ( QNetworkRequest::RedirectionTargetAttribute );
@@ -2782,8 +2785,8 @@ void QgsWmsProvider::identifyReplyFinished()
27822785
27832786 QgsDebugMsg ( QString ( " redirected getfeatureinfo: %1" ).arg ( redirect.toString () ) );
27842787 mIdentifyReply = QgsNetworkAccessManager::instance ()->get ( QNetworkRequest ( redirect.toUrl () ) );
2788+ mIdentifyReply ->setProperty ( " eventLoop" , QVariant::fromValue ( qobject_cast<QObject *>( loop ) ) );
27852789 connect ( mIdentifyReply , SIGNAL ( finished () ), this , SLOT ( identifyReplyFinished () ) );
2786-
27872790 return ;
27882791 }
27892792
@@ -2794,8 +2797,6 @@ void QgsWmsProvider::identifyReplyFinished()
27942797 mErrorFormat = " text/plain" ;
27952798 mError = tr ( " Map getfeatureinfo error %1: %2" ).arg ( status.toInt () ).arg ( phrase.toString () );
27962799 emit statusChanged ( mError );
2797-
2798- // mIdentifyResult = "";
27992800 }
28002801
28012802 QgsNetworkReplyParser parser ( mIdentifyReply );
@@ -2805,7 +2806,6 @@ void QgsWmsProvider::identifyReplyFinished()
28052806 mErrorFormat = " text/plain" ;
28062807 mError = tr ( " Cannot parse getfeatureinfo: %1" ).arg ( parser.error () );
28072808 emit statusChanged ( mError );
2808- // mIdentifyResult = "";
28092809 }
28102810 else
28112811 {
@@ -2824,6 +2824,9 @@ void QgsWmsProvider::identifyReplyFinished()
28242824 QgsMessageLog::logMessage ( mError , tr ( " WMS" ) );
28252825 }
28262826
2827+ if ( loop )
2828+ QMetaObject::invokeMethod ( loop, " quit" , Qt::QueuedConnection );
2829+
28272830 mIdentifyReply ->deleteLater ();
28282831 mIdentifyReply = 0 ;
28292832}
@@ -3016,12 +3019,11 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh )
30163019
30173020 QgsDebugMsg ( QString ( " getlegendgraphics: %1" ).arg ( url.toString () ) );
30183021 mGetLegendGraphicReply = QgsNetworkAccessManager::instance ()->get ( request );
3019-
30203022 connect ( mGetLegendGraphicReply , SIGNAL ( finished () ), this , SLOT ( getLegendGraphicReplyFinished () ) );
30213023 connect ( mGetLegendGraphicReply , SIGNAL ( downloadProgress ( qint64, qint64 ) ), this , SLOT ( getLegendGraphicReplyProgress ( qint64, qint64 ) ) );
30223024
30233025 QEventLoop loop;
3024- connect ( mGetLegendGraphicReply , SIGNAL ( finished () ), &loop, SLOT ( quit ( ) ) );
3026+ mGetLegendGraphicReply -> setProperty ( " eventLoop " , QVariant::fromValue ( qobject_cast<QObject *>( &loop ) ) );
30253027 loop.exec ( QEventLoop::ExcludeUserInputEvents );
30263028
30273029 QgsDebugMsg ( " exiting." );
@@ -3033,6 +3035,8 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
30333035{
30343036 QgsDebugMsg ( " entering." );
30353037
3038+ QEventLoop *loop = qobject_cast< QEventLoop *>( sender ()->property ( " eventLoop" ).value < QObject *>() );
3039+
30363040 if ( mGetLegendGraphicReply ->error () == QNetworkReply::NoError )
30373041 {
30383042 QgsDebugMsg ( " reply ok" );
@@ -3060,6 +3064,7 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
30603064 mGetLegendGraphicReply ->deleteLater ();
30613065 QgsDebugMsg ( QString ( " redirected GetLegendGraphic: %1" ).arg ( redirect.toString () ) );
30623066 mGetLegendGraphicReply = QgsNetworkAccessManager::instance ()->get ( request );
3067+ mIdentifyReply ->setProperty ( " eventLoop" , QVariant::fromValue ( qobject_cast<QObject *>( loop ) ) );
30633068
30643069 connect ( mGetLegendGraphicReply , SIGNAL ( finished () ), this , SLOT ( getLegendGraphicReplyFinished () ) );
30653070 connect ( mGetLegendGraphicReply , SIGNAL ( downloadProgress ( qint64, qint64 ) ), this , SLOT ( getLegendGraphicReplyProgress ( qint64, qint64 ) ) );
@@ -3099,6 +3104,9 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
30993104 mHttpGetLegendGraphicResponse .clear ();
31003105 }
31013106
3107+ if ( loop )
3108+ QMetaObject::invokeMethod ( loop, " quit" , Qt::QueuedConnection );
3109+
31023110 mGetLegendGraphicReply ->deleteLater ();
31033111 mGetLegendGraphicReply = 0 ;
31043112}
0 commit comments