# HG changeset patch # User Chris Cannam # Date 1403005947 -3600 # Node ID 926f33d3a8b7d493e29a9e9a19614a2901351d21 # Parent 55e552b4f1b71ecc47d14a2e14dd0da4c387cde8# Parent 49618f39ff091e72eb94dd0d8424da44cf10e272 Merge from default branch diff -r 55e552b4f1b7 -r 926f33d3a8b7 data/fileio/FileSource.cpp --- a/data/fileio/FileSource.cpp Tue May 13 09:50:59 2014 +0100 +++ b/data/fileio/FileSource.cpp Tue Jun 17 12:52:27 2014 +0100 @@ -485,7 +485,10 @@ if (m_reply) { QNetworkReply *r = m_reply; m_reply = 0; - r->abort(); + // Can only call abort() when there are no errors. + if (r->error() == QNetworkReply::NoError) { + r->abort(); + } r->deleteLater(); } if (m_localFile) { @@ -518,11 +521,14 @@ { waitForStatus(); bool available = true; - if (!m_ok) available = false; - else available = (m_lastStatus / 100 == 2); + if (!m_ok) { + available = false; + } else { + // http 2xx status codes mean success + available = (m_lastStatus / 100 == 2); + } #ifdef DEBUG_FILE_SOURCE - cerr << "FileSource::isAvailable: " << (available ? "yes" : "no") - << endl; + cerr << "FileSource::isAvailable: " << (available ? "yes" : "no") << endl; #endif return available; } @@ -634,9 +640,12 @@ return; } + // Handle http transfer status codes. + int status = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + // If this is a redirection (3xx) code, do the redirect if (status / 100 == 3) { QString location = m_reply->header (QNetworkRequest::LocationHeader).toString(); @@ -665,6 +674,8 @@ } m_lastStatus = status; + + // 400 and up are failures, get the error string if (m_lastStatus / 100 >= 4) { m_errorString = QString("%1 %2") .arg(status) @@ -713,6 +724,13 @@ if (m_done) return; + QString scheme = m_url.scheme().toLower(); + // For ftp transfers, replyFinished() will be called on success. + // metaDataChanged() is never called for ftp transfers. + if (scheme == "ftp") { + m_lastStatus = 200; // http ok + } + bool error = (m_lastStatus / 100 >= 4); cleanup(); diff -r 55e552b4f1b7 -r 926f33d3a8b7 data/model/FlexiNoteModel.h --- a/data/model/FlexiNoteModel.h Tue May 13 09:50:59 2014 +0100 +++ b/data/model/FlexiNoteModel.h Tue Jun 17 12:52:27 2014 +0100 @@ -226,25 +226,22 @@ * NoteExportable methods. */ - NoteList getNotes() const { + NoteList getNotes() const + { return getNotes(getStartFrame(), getEndFrame()); } - NoteList getNotes(size_t startFrame, size_t endFrame) const { - - PointList points = getPoints(startFrame, endFrame); + NoteList getNotes(size_t startFrame, size_t endFrame) const + { + PointList points = getPoints(startFrame, endFrame); NoteList notes; - - for (PointList::iterator pli = - points.begin(); pli != points.end(); ++pli) { - - size_t duration = pli->duration; + for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) { + size_t duration = pli->duration; if (duration == 0 || duration == 1) { duration = getSampleRate() / 20; } + int pitch = lrintf(pli->value); - int pitch = lrintf(pli->value); - int velocity = 100; if (pli->level > 0.f && pli->level <= 1.f) { velocity = lrintf(pli->level * 127); @@ -257,10 +254,8 @@ note.midiPitch = Pitch::getPitchForFrequency(note.frequency); note.isMidiPitchQuantized = false; } - notes.push_back(note); } - return notes; }