@@ -2367,7 +2367,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
2367
2367
connect ( mIdentifyReply , SIGNAL ( finished () ), this , SLOT ( identifyReplyFinished () ) );
2368
2368
2369
2369
QEventLoop loop;
2370
- connect ( mIdentifyReply , SIGNAL ( finished () ), &loop, SLOT ( quit ( ) ) );
2370
+ mIdentifyReply -> setProperty ( " eventLoop " , QVariant::fromValue ( qobject_cast<QObject *>( &loop ) ) );
2371
2371
loop.exec ( QEventLoop::ExcludeUserInputEvents );
2372
2372
2373
2373
if ( mIdentifyResultBodies .size () == 0 ) // no result
@@ -2767,9 +2767,12 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
2767
2767
2768
2768
void QgsWmsProvider::identifyReplyFinished ()
2769
2769
{
2770
+ QgsDebugMsg ( " Entered." );
2770
2771
mIdentifyResultHeaders .clear ();
2771
2772
mIdentifyResultBodies .clear ();
2772
2773
2774
+ QEventLoop *loop = qobject_cast< QEventLoop *>( sender ()->property ( " eventLoop" ).value < QObject *>() );
2775
+
2773
2776
if ( mIdentifyReply ->error () == QNetworkReply::NoError )
2774
2777
{
2775
2778
QVariant redirect = mIdentifyReply ->attribute ( QNetworkRequest::RedirectionTargetAttribute );
@@ -2782,8 +2785,8 @@ void QgsWmsProvider::identifyReplyFinished()
2782
2785
2783
2786
QgsDebugMsg ( QString ( " redirected getfeatureinfo: %1" ).arg ( redirect.toString () ) );
2784
2787
mIdentifyReply = QgsNetworkAccessManager::instance ()->get ( QNetworkRequest ( redirect.toUrl () ) );
2788
+ mIdentifyReply ->setProperty ( " eventLoop" , QVariant::fromValue ( qobject_cast<QObject *>( loop ) ) );
2785
2789
connect ( mIdentifyReply , SIGNAL ( finished () ), this , SLOT ( identifyReplyFinished () ) );
2786
-
2787
2790
return ;
2788
2791
}
2789
2792
@@ -2794,8 +2797,6 @@ void QgsWmsProvider::identifyReplyFinished()
2794
2797
mErrorFormat = " text/plain" ;
2795
2798
mError = tr ( " Map getfeatureinfo error %1: %2" ).arg ( status.toInt () ).arg ( phrase.toString () );
2796
2799
emit statusChanged ( mError );
2797
-
2798
- // mIdentifyResult = "";
2799
2800
}
2800
2801
2801
2802
QgsNetworkReplyParser parser ( mIdentifyReply );
@@ -2805,7 +2806,6 @@ void QgsWmsProvider::identifyReplyFinished()
2805
2806
mErrorFormat = " text/plain" ;
2806
2807
mError = tr ( " Cannot parse getfeatureinfo: %1" ).arg ( parser.error () );
2807
2808
emit statusChanged ( mError );
2808
- // mIdentifyResult = "";
2809
2809
}
2810
2810
else
2811
2811
{
@@ -2824,6 +2824,9 @@ void QgsWmsProvider::identifyReplyFinished()
2824
2824
QgsMessageLog::logMessage ( mError , tr ( " WMS" ) );
2825
2825
}
2826
2826
2827
+ if ( loop )
2828
+ QMetaObject::invokeMethod ( loop, " quit" , Qt::QueuedConnection );
2829
+
2827
2830
mIdentifyReply ->deleteLater ();
2828
2831
mIdentifyReply = 0 ;
2829
2832
}
@@ -3016,12 +3019,11 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh )
3016
3019
3017
3020
QgsDebugMsg ( QString ( " getlegendgraphics: %1" ).arg ( url.toString () ) );
3018
3021
mGetLegendGraphicReply = QgsNetworkAccessManager::instance ()->get ( request );
3019
-
3020
3022
connect ( mGetLegendGraphicReply , SIGNAL ( finished () ), this , SLOT ( getLegendGraphicReplyFinished () ) );
3021
3023
connect ( mGetLegendGraphicReply , SIGNAL ( downloadProgress ( qint64, qint64 ) ), this , SLOT ( getLegendGraphicReplyProgress ( qint64, qint64 ) ) );
3022
3024
3023
3025
QEventLoop loop;
3024
- connect ( mGetLegendGraphicReply , SIGNAL ( finished () ), &loop, SLOT ( quit ( ) ) );
3026
+ mGetLegendGraphicReply -> setProperty ( " eventLoop " , QVariant::fromValue ( qobject_cast<QObject *>( &loop ) ) );
3025
3027
loop.exec ( QEventLoop::ExcludeUserInputEvents );
3026
3028
3027
3029
QgsDebugMsg ( " exiting." );
@@ -3033,6 +3035,8 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
3033
3035
{
3034
3036
QgsDebugMsg ( " entering." );
3035
3037
3038
+ QEventLoop *loop = qobject_cast< QEventLoop *>( sender ()->property ( " eventLoop" ).value < QObject *>() );
3039
+
3036
3040
if ( mGetLegendGraphicReply ->error () == QNetworkReply::NoError )
3037
3041
{
3038
3042
QgsDebugMsg ( " reply ok" );
@@ -3060,6 +3064,7 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
3060
3064
mGetLegendGraphicReply ->deleteLater ();
3061
3065
QgsDebugMsg ( QString ( " redirected GetLegendGraphic: %1" ).arg ( redirect.toString () ) );
3062
3066
mGetLegendGraphicReply = QgsNetworkAccessManager::instance ()->get ( request );
3067
+ mIdentifyReply ->setProperty ( " eventLoop" , QVariant::fromValue ( qobject_cast<QObject *>( loop ) ) );
3063
3068
3064
3069
connect ( mGetLegendGraphicReply , SIGNAL ( finished () ), this , SLOT ( getLegendGraphicReplyFinished () ) );
3065
3070
connect ( mGetLegendGraphicReply , SIGNAL ( downloadProgress ( qint64, qint64 ) ), this , SLOT ( getLegendGraphicReplyProgress ( qint64, qint64 ) ) );
@@ -3099,6 +3104,9 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
3099
3104
mHttpGetLegendGraphicResponse .clear ();
3100
3105
}
3101
3106
3107
+ if ( loop )
3108
+ QMetaObject::invokeMethod ( loop, " quit" , Qt::QueuedConnection );
3109
+
3102
3110
mGetLegendGraphicReply ->deleteLater ();
3103
3111
mGetLegendGraphicReply = 0 ;
3104
3112
}
0 commit comments