exclude-annotation-files.diff

Patch to refuse opening annotation files - Chris Cannam, 2019-11-22 11:07 AM

Download (2.67 KB)

View differences:

main/MainWindow.cpp Fri Nov 22 11:07:06 2019 +0000
54 54
#include "data/fileio/CSVFormat.h"
55 55
#include "data/fileio/CSVFileWriter.h"
56 56
#include "data/fileio/MIDIFileWriter.h"
57
#include "data/fileio/AudioFileReaderFactory.h"
57 58
#include "rdf/RDFExporter.h"
58 59

  
59 60
#include "widgets/RangeInputDialog.h"
60 61
#include "widgets/ActivityLog.h"
62
#include "widgets/InteractiveFileFinder.h"
63
#include "widgets/ProgressDialog.h"
61 64

  
62 65
// For version information
63 66
#include "vamp/vamp.h"
......
1761 1764
    if (orig == "") orig = ".";
1762 1765
    else orig = QFileInfo(orig).absoluteDir().canonicalPath();
1763 1766

  
1764
    QString path = getOpenFileName(FileFinder::AnyFile);
1765

  
1767
    QString path = getOpenFileName(FileFinder::SessionOrAudioFile);
1766 1768
    if (path.isEmpty()) return;
1767 1769

  
1768
    FileOpenStatus status = openPath(path, ReplaceSession);
1770
    FileSource source(path);
1771

  
1772
    FileOpenStatus status = FileOpenFailed;
1773
    
1774
    if (source.isAvailable()) {
1775

  
1776
        QString ext = source.getExtension().toLower();
1777
        
1778
        bool isAudio =
1779
            AudioFileReaderFactory::getKnownExtensions().contains(ext);
1780

  
1781
        bool isSession = InteractiveFileFinder::getInstance()->
1782
            getApplicationSessionExtension() == ext;
1783

  
1784
        if (isAudio || isSession) {
1785
            source.waitForData();
1786
            status = open(source, ReplaceSession);
1787
        }
1788
    }
1769 1789

  
1770 1790
    if (status == FileOpenFailed) {
1771 1791
        QMessageBox::critical(this, tr("Failed to open file"),
......
1790 1810
         QLineEdit::Normal, lastLocation, &ok);
1791 1811

  
1792 1812
    if (!ok) return;
1813
    if (text.isEmpty()) return;
1793 1814

  
1794 1815
    settings.setValue("lastremote", text);
1795 1816

  
1796
    if (text.isEmpty()) return;
1797

  
1798
    FileOpenStatus status = openPath(text, ReplaceSession);
1817
    FileOpenStatus status = FileOpenFailed;
1818

  
1819
    {
1820
        ProgressDialog dialog(tr("Opening file or URL..."), true, 2000, this);
1821
        connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
1822
        FileSource source(text, &dialog);
1823
    
1824
        if (source.isAvailable()) {
1825

  
1826
            QString ext = source.getExtension().toLower();
1827
        
1828
            bool isAudio =
1829
                AudioFileReaderFactory::getKnownExtensions().contains(ext);
1830

  
1831
            bool isSession = InteractiveFileFinder::getInstance()->
1832
                getApplicationSessionExtension() == ext;
1833

  
1834
            if (isAudio || isSession) {
1835
                source.waitForData();
1836
                status = open(source, ReplaceSession);
1837
            }
1838
        }
1839
    }
1799 1840

  
1800 1841
    if (status == FileOpenFailed) {
1801 1842
        QMessageBox::critical(this, tr("Failed to open location"),