Mercurial > hg > svcore
diff data/fileio/FileSource.cpp @ 497:b6dc6c7f402c
Various fixes:
* Fix handling of HTTP redirects (avoiding crashes... I hope)
* Fix failure to delete FFT models when a feature extraction model
transformer was abandoned (also a cause of crashes in the past)
* Fix deadlock when said transform was abandoned before its source
model was ready because the session was being cleared (and so the
source model would never be ready)
author | Chris Cannam |
---|---|
date | Fri, 28 Nov 2008 13:36:13 +0000 |
parents | 05383ee78f3e |
children | bd7c46636bd0 |
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp Thu Nov 27 22:09:58 2008 +0000 +++ b/data/fileio/FileSource.cpp Fri Nov 28 13:36:13 2008 +0000 @@ -29,7 +29,7 @@ #include <iostream> #include <cstdlib> -#define DEBUG_FILE_SOURCE 1 +//#define DEBUG_FILE_SOURCE 1 int FileSource::m_count = 0; @@ -108,6 +108,8 @@ emit statusAvailable(); emit ready(); } + + std::cerr << "FileSource::FileSource(string) exiting" << std::endl; } FileSource::FileSource(QUrl url, ProgressReporter *reporter) : @@ -134,6 +136,8 @@ } init(); + + std::cerr << "FileSource::FileSource(url) exiting" << std::endl; } FileSource::FileSource(const FileSource &rf) : @@ -182,6 +186,8 @@ } m_done = true; + + std::cerr << "FileSource::FileSource(copy ctor) exiting" << std::endl; } FileSource::~FileSource() @@ -311,7 +317,8 @@ FileSource::initHttp() { m_ok = true; - m_http = new QHttp(m_url.host(), m_url.port(80)); + int port = m_url.port(); + m_http = new QHttp(m_url.host(), port < 0 ? 80 : port); connect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool))); connect(m_http, SIGNAL(dataReadProgress(int, int)), this, SLOT(dataReadProgress(int, int))); @@ -475,6 +482,7 @@ while (m_ok && !m_done) { // std::cerr << "FileSource::waitForData: calling QApplication::processEvents" << std::endl; QCoreApplication::processEvents(); + usleep(10000); } } @@ -545,8 +553,9 @@ void FileSource::httpResponseHeaderReceived(const QHttpResponseHeader &resp) { - m_lastStatus = resp.statusCode(); - if (m_lastStatus / 100 == 3) { + std::cerr << "FileSource::httpResponseHeaderReceived" << std::endl; + + if (resp.statusCode() / 100 == 3) { QString location = resp.value("Location"); #ifdef DEBUG_FILE_SOURCE std::cerr << "FileSource::responseHeaderReceived: redirect to \"" @@ -555,19 +564,20 @@ if (location != "") { QUrl newUrl(location); if (newUrl != m_url) { + cleanup(); + deleteCacheFile(); m_url = newUrl; + m_localFile = 0; m_lastStatus = 0; - disconnect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool))); - disconnect(m_http, SIGNAL(dataReadProgress(int, int)), - this, SLOT(dataReadProgress(int, int))); - m_http->abort(); - m_http->deleteLater(); - m_http = 0; + m_done = false; + m_refCounted = false; init(); return; } } } + + m_lastStatus = resp.statusCode(); if (m_lastStatus / 100 >= 4) { m_errorString = QString("%1 %2") .arg(resp.statusCode()).arg(resp.reasonPhrase());