changeset 152:6f1e64670451

* Fix crash in SimpleSPARQLQuery * Fix failure to add images from local files
author Chris Cannam
date Thu, 15 Jan 2009 18:20:40 +0000
parents f8110d1a3a37
children 99afa5fa8d30
files framework/MainWindowBase.cpp
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Fri Dec 12 17:06:33 2008 +0000
+++ b/framework/MainWindowBase.cpp	Thu Jan 15 18:20:40 2009 +0000
@@ -53,6 +53,7 @@
 #include "data/fileio/MIDIFileWriter.h"
 #include "data/fileio/BZipFileDevice.h"
 #include "data/fileio/FileSource.h"
+#include "data/fileio/AudioFileReaderFactory.h"
 #include "rdf/RDFImporter.h"
 
 #include "data/fft/FFTDataServer.h"
@@ -859,9 +860,12 @@
                            m_paneStack != 0 &&
                            m_paneStack->getCurrentPane() != 0);
 
-    bool rdf = (source.getExtension() == "rdf" ||
-                source.getExtension() == "n3" ||
-                source.getExtension() == "ttl");
+    bool rdf = (source.getExtension().toLower() == "rdf" ||
+                source.getExtension().toLower() == "n3" ||
+                source.getExtension().toLower() == "ttl");
+
+    bool audio = AudioFileReaderFactory::getKnownExtensions().contains
+        (source.getExtension().toLower());
 
     bool rdfSession = false;
     if (rdf) {
@@ -900,7 +904,7 @@
         }
     }
 
-    if ((status = openAudio(source, mode)) != FileOpenFailed) {
+    if (audio && (status = openAudio(source, mode)) != FileOpenFailed) {
         return status;
     } else if ((status = openSession(source)) != FileOpenFailed) {
 	return status;
@@ -1118,7 +1122,7 @@
 
     std::set<QString> extensions;
     PlaylistFileReader::getSupportedExtensions(extensions);
-    QString extension = source.getExtension();
+    QString extension = source.getExtension().toLower();
     if (extensions.find(extension) == extensions.end()) return FileOpenFailed;
 
     if (!source.isAvailable()) return FileOpenFailed;
@@ -1185,8 +1189,8 @@
 
         return openLayersFromRDF(source);
 
-    } else if (source.getExtension() == "svl" ||
-               (source.getExtension() == "xml" &&
+    } else if (source.getExtension().toLower() == "svl" ||
+               (source.getExtension().toLower() == "xml" &&
                 (SVFileReader::identifyXmlFile(source.getLocalFilename())
                  == SVFileReader::SVLayerFile))) {
 
@@ -1347,7 +1351,7 @@
     if (!source.isAvailable()) return FileOpenFailed;
     source.waitForData();
 
-    if (source.getExtension() != "sv") {
+    if (source.getExtension().toLower() != "sv") {
 
         RDFImporter::RDFDocumentType rdfType = 
             RDFImporter::identifyDocumentType
@@ -1362,7 +1366,7 @@
             return FileOpenFailed;
         }
 
-        if (source.getExtension() == "xml") {
+        if (source.getExtension().toLower() == "xml") {
             if (SVFileReader::identifyXmlFile(source.getLocalFilename()) ==
                 SVFileReader::SVSessionFile) {
                 std::cerr << "This XML file looks like a session file, attempting to open it as a session" << std::endl;
@@ -1378,7 +1382,7 @@
     BZipFileDevice *bzFile = 0;
     QFile *rawFile = 0;
 
-    if (source.getExtension() == "sv") {
+    if (source.getExtension().toLower() == "sv") {
         bzFile = new BZipFileDevice(source.getLocalFilename());
         if (!bzFile->open(QIODevice::ReadOnly)) {
             delete bzFile;