diff document/SVFileReader.cpp @ 197:c08c312b2399

* Make RemoteFile far more pervasive, and use it for local files as well so that we can handle both transparently. Make it shallow copy with reference counting, so it can be used by value without having to worry about the cache file lifetime. Use RemoteFile for MainWindow file-open functions, etc
author Chris Cannam
date Thu, 18 Oct 2007 15:31:20 +0000
parents 7b943924b8d3
children 24ac2e4010c5
line wrap: on
line diff
--- a/document/SVFileReader.cpp	Thu Oct 18 10:15:07 2007 +0000
+++ b/document/SVFileReader.cpp	Thu Oct 18 15:31:20 2007 +0000
@@ -412,25 +412,18 @@
         QString originalPath = attributes.value("file");
         QString path = ff->find(FileFinder::AudioFile,
                                 originalPath, m_location);
-        QUrl url(path);
 
-        if (RemoteFile::canHandleScheme(url)) {
+        RemoteFile file(path);
+        file.waitForStatus();
 
-            RemoteFile rf(url);
-            rf.wait();
-
-            if (rf.isOK()) {
-
-                model = new WaveFileModel(rf.getLocalFilename(), path);
-                if (!model->isOK()) {
-                    delete model;
-                    model = 0;
-                    //!!! and delete local file?
-                }
-            }
+        if (!file.isOK()) {
+            std::cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path.toStdString() << "\" for wave file model: " << file.getErrorString().toStdString() << std::endl;
+        } else if (!file.isAvailable()) {
+            std::cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path.toStdString() << "\" for wave file model: Source unavailable" << std::endl;
         } else {
 
-            model = new WaveFileModel(path);
+            file.waitForData();
+            model = new WaveFileModel(file);
             if (!model->isOK()) {
                 delete model;
                 model = 0;