Mercurial > hg > svcore
comparison data/fileio/FileSource.cpp @ 1599:ce185d4dd408 bqaudiostream
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 23 Jan 2019 14:43:43 +0000 |
parents | 70e172e6cc59 |
children | 7001b9570e37 |
comparison
equal
deleted
inserted
replaced
1598:d2555df635ec | 1599:ce185d4dd408 |
---|---|
89 | 89 |
90 FileSource::FileSource(QString fileOrUrl, ProgressReporter *reporter, | 90 FileSource::FileSource(QString fileOrUrl, ProgressReporter *reporter, |
91 QString preferredContentType) : | 91 QString preferredContentType) : |
92 m_rawFileOrUrl(fileOrUrl), | 92 m_rawFileOrUrl(fileOrUrl), |
93 m_url(fileOrUrl, QUrl::StrictMode), | 93 m_url(fileOrUrl, QUrl::StrictMode), |
94 m_localFile(0), | 94 m_localFile(nullptr), |
95 m_reply(0), | 95 m_reply(nullptr), |
96 m_preferredContentType(preferredContentType), | 96 m_preferredContentType(preferredContentType), |
97 m_ok(false), | 97 m_ok(false), |
98 m_cancelled(false), | 98 m_cancelled(false), |
99 m_lastStatus(0), | 99 m_lastStatus(0), |
100 m_resource(fileOrUrl.startsWith(':')), | 100 m_resource(fileOrUrl.startsWith(':')), |
180 #endif | 180 #endif |
181 } | 181 } |
182 | 182 |
183 FileSource::FileSource(QUrl url, ProgressReporter *reporter) : | 183 FileSource::FileSource(QUrl url, ProgressReporter *reporter) : |
184 m_url(url), | 184 m_url(url), |
185 m_localFile(0), | 185 m_localFile(nullptr), |
186 m_reply(0), | 186 m_reply(nullptr), |
187 m_ok(false), | 187 m_ok(false), |
188 m_cancelled(false), | 188 m_cancelled(false), |
189 m_lastStatus(0), | 189 m_lastStatus(0), |
190 m_resource(false), | 190 m_resource(false), |
191 m_remote(isRemote(url.toString())), | 191 m_remote(isRemote(url.toString())), |
213 } | 213 } |
214 | 214 |
215 FileSource::FileSource(const FileSource &rf) : | 215 FileSource::FileSource(const FileSource &rf) : |
216 QObject(), | 216 QObject(), |
217 m_url(rf.m_url), | 217 m_url(rf.m_url), |
218 m_localFile(0), | 218 m_localFile(nullptr), |
219 m_reply(0), | 219 m_reply(nullptr), |
220 m_ok(rf.m_ok), | 220 m_ok(rf.m_ok), |
221 m_cancelled(rf.m_cancelled), | 221 m_cancelled(rf.m_cancelled), |
222 m_lastStatus(rf.m_lastStatus), | 222 m_lastStatus(rf.m_lastStatus), |
223 m_resource(rf.m_resource), | 223 m_resource(rf.m_resource), |
224 m_remote(rf.m_remote), | 224 m_remote(rf.m_remote), |
383 #endif | 383 #endif |
384 | 384 |
385 qint64 written = m_localFile->write(ba); | 385 qint64 written = m_localFile->write(ba); |
386 m_localFile->close(); | 386 m_localFile->close(); |
387 delete m_localFile; | 387 delete m_localFile; |
388 m_localFile = 0; | 388 m_localFile = nullptr; |
389 | 389 |
390 if (written != ba.size()) { | 390 if (written != ba.size()) { |
391 #ifdef DEBUG_FILE_SOURCE | 391 #ifdef DEBUG_FILE_SOURCE |
392 cerr << "Copy failed (wrote " << written << " bytes)" << endl; | 392 cerr << "Copy failed (wrote " << written << " bytes)" << endl; |
393 #endif | 393 #endif |
500 void | 500 void |
501 FileSource::cleanup() | 501 FileSource::cleanup() |
502 { | 502 { |
503 if (m_done) { | 503 if (m_done) { |
504 delete m_localFile; // does not actually delete the file | 504 delete m_localFile; // does not actually delete the file |
505 m_localFile = 0; | 505 m_localFile = nullptr; |
506 } | 506 } |
507 m_done = true; | 507 m_done = true; |
508 if (m_reply) { | 508 if (m_reply) { |
509 QNetworkReply *r = m_reply; | 509 QNetworkReply *r = m_reply; |
510 disconnect(r, 0, this, 0); | 510 disconnect(r, nullptr, this, nullptr); |
511 m_reply = 0; | 511 m_reply = nullptr; |
512 // Can only call abort() when there are no errors. | 512 // Can only call abort() when there are no errors. |
513 if (r->error() == QNetworkReply::NoError) { | 513 if (r->error() == QNetworkReply::NoError) { |
514 r->abort(); | 514 r->abort(); |
515 } | 515 } |
516 r->deleteLater(); | 516 r->deleteLater(); |
517 } | 517 } |
518 if (m_localFile) { | 518 if (m_localFile) { |
519 delete m_localFile; // does not actually delete the file | 519 delete m_localFile; // does not actually delete the file |
520 m_localFile = 0; | 520 m_localFile = nullptr; |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 bool | 524 bool |
525 FileSource::isRemote(QString fileOrUrl) | 525 FileSource::isRemote(QString fileOrUrl) |
691 #ifdef DEBUG_FILE_SOURCE | 691 #ifdef DEBUG_FILE_SOURCE |
692 decCount(m_url.toString()); | 692 decCount(m_url.toString()); |
693 incCount(newUrl.toString()); | 693 incCount(newUrl.toString()); |
694 #endif | 694 #endif |
695 m_url = newUrl; | 695 m_url = newUrl; |
696 m_localFile = 0; | 696 m_localFile = nullptr; |
697 m_lastStatus = 0; | 697 m_lastStatus = 0; |
698 m_done = false; | 698 m_done = false; |
699 m_refCounted = false; | 699 m_refCounted = false; |
700 init(); | 700 init(); |
701 return; | 701 return; |