Mercurial > hg > svapp
changeset 762:83ae68de4401
Return a "wrong mode" error (i.e. audio required before annotation) from open() only when looking at a document that is plausibly importable as an annotation in the first place
author | Chris Cannam |
---|---|
date | Mon, 11 May 2020 17:29:17 +0100 |
parents | 3a63f1f61bd6 |
children | 4c91c95e146a |
files | framework/MainWindowBase.cpp |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Thu Apr 30 14:48:14 2020 +0100 +++ b/framework/MainWindowBase.cpp Mon May 11 17:29:17 2020 +0100 @@ -59,6 +59,7 @@ #include "data/fileio/BZipFileDevice.h" #include "data/fileio/FileSource.h" #include "data/fileio/AudioFileReaderFactory.h" +#include "data/fileio/TextTest.h" #include "rdf/RDFImporter.h" #include "rdf/RDFExporter.h" @@ -1516,7 +1517,20 @@ } else if ((status = openPlaylist(source, mode)) != FileOpenFailed) { return status; } else if (!canImportLayer) { - return FileOpenWrongMode; + // We already checked whether the file is RDF: we know + // it's not. But if it's another format that might be + // supported as a layer, reply that we can't open a layer + // here - otherwise assume it's an unknown file format + if (ImageLayer::isImageFileSupported(source.getLocation())) { + return FileOpenWrongMode; + } + if (extension == "mid" || extension == "midi") { + return FileOpenWrongMode; + } + if (TextTest::isApparentTextDocument(source)) { + return FileOpenWrongMode; + } + return FileOpenFailed; } else if ((status = openImage(source)) != FileOpenFailed) { return status; } else if ((status = openLayer(source)) != FileOpenFailed) { @@ -2057,7 +2071,7 @@ // We don't put the image file in Recent Files - cerr << "openImage: trying location \"" << source.getLocation() << "\" in image layer" << endl; + SVCERR << "openImage: trying location \"" << source.getLocation() << "\" in image layer" << endl; if (!il->addImage(m_viewManager->getGlobalCentreFrame(), source.getLocation())) { if (newLayer) {