Skip to content

Commit 07a42c1

Browse files
author
morb_au
committed
A further speculative fix for trac ticket #8.
QgsHttpTransaction needed to wait for the done() signal from QHttp, not just requestFinished(). When QHttp::setProxy() was called, it actually triggered its own QHttp request (before QHttp::get()). Previously QgsHttpTransaction interpreted the requestFinished() from setProxy() as the requestFinished() from get(), therefore not actually doing anything when a proxy was used. I cannot test until a Windows build is available based on this commit (or somebody else can confirm instead and update #8 appropriately). git-svn-id: http://svn.osgeo.org/qgis/trunk@5697 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 52e80e9 commit 07a42c1

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/providers/wms/qgshttptransaction.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ bool QgsHttpTransaction::getSynchronously(QByteArray &respondedContent, int redi
139139
connect(http, SIGNAL( requestFinished ( int, bool ) ),
140140
this, SLOT( dataFinished ( int, bool ) ) );
141141

142+
connect(http, SIGNAL( done ( bool ) ),
143+
this, SLOT( transactionFinished ( bool ) ) );
144+
142145
connect(http, SIGNAL( stateChanged ( int ) ),
143146
this, SLOT( dataStateChanged ( int ) ) );
144147

@@ -313,6 +316,7 @@ void QgsHttpTransaction::dataProgress( int done, int total )
313316
emit setStatus( status );
314317
}
315318

319+
316320
void QgsHttpTransaction::dataFinished( int id, bool error )
317321
{
318322

@@ -348,6 +352,56 @@ void QgsHttpTransaction::dataFinished( int id, bool error )
348352
}
349353
#endif
350354

355+
// Don't do this here as the request could have simply been
356+
// to set the hostname - see transactionFinished() instead
357+
358+
// // TODO
359+
// httpresponse = http->readAll();
360+
//
361+
// #ifdef QGISDEBUG
362+
// std::cout << "QgsHttpTransaction::getSynchronously: Setting httpactive = FALSE" << std::endl;
363+
// #endif
364+
// httpactive = FALSE;
365+
366+
}
367+
368+
369+
void QgsHttpTransaction::transactionFinished( bool error )
370+
{
371+
372+
#ifdef QGISDEBUG
373+
std::cout << "QgsHttpTransaction::transactionFinished"
374+
<< "." << std::endl;
375+
376+
// // The signal that this slot is connected to, QHttp::requestFinished,
377+
// // appears to get called at the destruction of the QHttp if it is
378+
// // still working at the time of the destruction.
379+
// //
380+
// // This situation may occur when we've detected a timeout and
381+
// // we already set httpactive = FALSE.
382+
// //
383+
// // We have to detect this special case so that the last known error string is
384+
// // not overwritten (it should rightfully refer to the timeout event).
385+
// if (!httpactive)
386+
// {
387+
// std::cout << "QgsHttpTransaction::dataFinished - http activity loop already FALSE." << std::endl;
388+
// return;
389+
// }
390+
391+
if (error)
392+
{
393+
std::cout << "QgsHttpTransaction::transactionFinished - however there was an error." << std::endl;
394+
std::cout << "QgsHttpTransaction::transactionFinished - " << http->errorString().toLocal8Bit().data() << std::endl;
395+
396+
mError = QString( tr("HTTP transaction completed, however there was an error: %1") )
397+
.arg( http->errorString() );
398+
}
399+
else
400+
{
401+
std::cout << "QgsHttpTransaction::transactionFinished - no error." << std::endl;
402+
}
403+
#endif
404+
351405
// TODO
352406
httpresponse = http->readAll();
353407

@@ -358,6 +412,7 @@ void QgsHttpTransaction::dataFinished( int id, bool error )
358412

359413
}
360414

415+
361416
void QgsHttpTransaction::dataStateChanged( int state )
362417
{
363418

src/providers/wms/qgshttptransaction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public slots:
9393

9494
void dataFinished( int id, bool error );
9595

96+
void transactionFinished( bool error );
97+
9698
void dataStateChanged( int state );
9799

98100
void networkTimedOut();

0 commit comments

Comments
 (0)