From b7548b7b7acb02f3eff84bdef5dfa03b6c61bfe5 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 4 Aug 2024 15:30:42 +0200 Subject: [PATCH] Warn about LADSPA problems (#7267) Introduce a method which checks if a file that's loaded has the LADSPA controls saved in an old format that was written with a version before commit e99efd541a9. The method is run at the end so that problems in all file versions are detected. If a real upgrade was to be implemented it would have to run between `DataFile::upgrade_0_4_0_rc2` and `DataFile::upgrade_1_0_99`. See #5738 for more details. If a problematic file is encountered a warning dialog that provides the number of affected LADSPA plugins is shown. --- include/DataFile.h | 1 + src/core/DataFile.cpp | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/DataFile.h b/include/DataFile.h index 5005c11bc..7f5f5b888 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -133,6 +133,7 @@ private: void upgrade_noteTypes(); void upgrade_fixCMTDelays(); void upgrade_fixBassLoopsTypo(); + void findProblematicLadspaPlugins(); // List of all upgrade methods static const std::vector UPGRADE_METHODS; diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index b664387bd..3e7d6d8b6 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -85,6 +85,7 @@ const std::vector DataFile::UPGRADE_METHODS = { &DataFile::upgrade_sampleAndHold , &DataFile::upgrade_midiCCIndexing, &DataFile::upgrade_loopsRename , &DataFile::upgrade_noteTypes, &DataFile::upgrade_fixCMTDelays , &DataFile::upgrade_fixBassLoopsTypo, + &DataFile::findProblematicLadspaPlugins }; // Vector of all versions that have upgrade routines. @@ -1072,7 +1073,6 @@ void DataFile::upgrade_0_4_0_rc2() } } - void DataFile::upgrade_1_0_99() { jo_id_t last_assigned_id = 0; @@ -1979,6 +1979,39 @@ void DataFile::upgrade_midiCCIndexing() } } +void DataFile::findProblematicLadspaPlugins() +{ + // This is not an upgrade but a check for potentially problematic LADSPA + // controls. See #5738 for more details. + + const QDomNodeList ladspacontrols = elementsByTagName("ladspacontrols"); + + uint numberOfProblematicPlugins = 0; + + for (int i = 0; i < ladspacontrols.size(); ++i) + { + const QDomElement ladspacontrol = ladspacontrols.item(i).toElement(); + + const auto attributes = ladspacontrol.attributes(); + for (int j = 0; j < attributes.length(); ++j) + { + const auto attribute = attributes.item(j); + const auto name = attribute.nodeName(); + if (name != "ports" && name.startsWith("port")) + { + ++numberOfProblematicPlugins; + break; + } + } + } + + if (numberOfProblematicPlugins > 0) + { + QMessageBox::warning(nullptr, QObject::tr("LADSPA plugins"), + QObject::tr("The project contains %1 LADSPA plugin(s) which might have not been restored correctly! Please check the project.").arg(numberOfProblematicPlugins)); + } +} + void DataFile::upgrade_fixBassLoopsTypo() { static const QMap replacementMap = {