From 4ec007ee1d238986eb73300f45173484c63f13ef Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 6 Jul 2014 01:27:16 +0100 Subject: [PATCH] Now using juce for engine/plugin file loading (plus xml) --- source/backend/engine/CarlaEngine.cpp | 122 +++++++++----------- source/backend/engine/CarlaEngineJack.cpp | 15 ++- source/backend/engine/CarlaEngineNative.cpp | 38 +++--- source/backend/engine/Makefile | 8 +- source/backend/plugin/CarlaPlugin.cpp | 63 +++++----- source/backend/plugin/Makefile | 2 +- source/utils/CarlaMutex.hpp | 4 +- source/utils/CarlaRingBuffer.hpp | 4 +- source/utils/CarlaStateUtils.cpp | 42 ++++--- source/utils/CarlaStateUtils.hpp | 16 +-- 10 files changed, 150 insertions(+), 164 deletions(-) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index d86358628..3e5d1e505 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -34,12 +34,14 @@ #include "CarlaMIDI.h" #include "jackbridge/JackBridge.hpp" +#include "juce_core.h" -#include -#include -#include -#include -#include +using juce::File; +using juce::MemoryOutputStream; +using juce::ScopedPointer; +using juce::String; +using juce::XmlDocument; +using juce::XmlElement; // ----------------------------------------------------------------------- @@ -1038,9 +1040,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons } } - QFile file(bridgeBinary.buffer()); + File file(bridgeBinary.buffer()); - if (! file.exists()) + if (! file.existsAsFile()) bridgeBinary.clear(); } @@ -1054,9 +1056,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons else if (btype == BINARY_WIN32) { // fallback to dssi-vst - QFileInfo fileInfo(filename); + File file(filename); - CarlaString label2(fileInfo.fileName().toUtf8().constData()); + CarlaString label2(file.getFullPathName().toRawUTF8()); label2.replace(' ', '*'); CarlaPlugin::Initializer init2 = { @@ -1069,7 +1071,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons }; char* const oldVstPath(getenv("VST_PATH")); - carla_setenv("VST_PATH", fileInfo.absoluteDir().absolutePath().toUtf8().constData()); + carla_setenv("VST_PATH", file.getParentDirectory().getFullPathName().toRawUTF8()); plugin = CarlaPlugin::newDSSI(init2); @@ -1525,28 +1527,11 @@ bool CarlaEngine::loadFile(const char* const filename) CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #1)"); carla_debug("CarlaEngine::loadFile(\"%s\")", filename); - QFileInfo fileInfo(filename); + File file(filename); + CARLA_SAFE_ASSERT_RETURN_ERR(file.existsAsFile(), "Requested file does not exist or is not a readable file"); - if (! fileInfo.exists()) - { - setLastError("File does not exist"); - return false; - } - - if (! fileInfo.isFile()) - { - setLastError("Not a file"); - return false; - } - - if (! fileInfo.isReadable()) - { - setLastError("File is not readable"); - return false; - } - - CarlaString baseName(fileInfo.baseName().toUtf8().constData()); - CarlaString extension(fileInfo.suffix().toLower().toUtf8().constData()); + CarlaString baseName(file.getFileName().toRawUTF8()); + CarlaString extension(file.getFileExtension().toRawUTF8()); extension.toLower(); // ------------------------------------------------------------------- @@ -1656,32 +1641,35 @@ bool CarlaEngine::loadProject(const char* const filename) CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #2)"); carla_debug("CarlaEngine::loadProject(\"%s\")", filename); - QFile file(filename); - - if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) - return false; + File file(filename); + CARLA_SAFE_ASSERT_RETURN_ERR(file.existsAsFile(), "Requested file does not exist or is not a readable file"); - QDomDocument xml; - xml.setContent(file.readAll()); - file.close(); + XmlDocument xml(file); + ScopedPointer xmlElement(xml.getDocumentElement(true)); + CARLA_SAFE_ASSERT_RETURN_ERR(xmlElement != nullptr, "Failed to parse project file"); - QDomNode xmlNode(xml.documentElement()); + const String& xmlType(xmlElement->getTagName()); + const bool isPreset(xmlType.equalsIgnoreCase("carla-preset")); - const bool isPreset(xmlNode.toElement().tagName().compare("carla-preset", Qt::CaseInsensitive) == 0); - - if (xmlNode.toElement().tagName().compare("carla-project", Qt::CaseInsensitive) != 0 && ! isPreset) + if (! (xmlType.equalsIgnoreCase("carla-project") || isPreset)) { setLastError("Not a valid Carla project or preset file"); return false; } + // completely load file + xmlElement = xml.getDocumentElement(false); + CARLA_SAFE_ASSERT_RETURN_ERR(xmlElement != nullptr, "Failed to completely parse project file"); + // handle plugins first - for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling()) + for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) { - if (isPreset || node.toElement().tagName().compare("plugin", Qt::CaseInsensitive) == 0) + const String& tagName(elem->getTagName()); + + if (isPreset || tagName.equalsIgnoreCase("plugin")) { StateSave stateSave; - stateSave.fillFromXmlNode(isPreset ? xmlNode : node); + stateSave.fillFromXmlElement(isPreset ? xmlElement.get() : elem); callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr); @@ -1725,30 +1713,34 @@ bool CarlaEngine::loadProject(const char* const filename) return true; } - // now connections - for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling()) + // now handle connections + for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) { - if (node.toElement().tagName().compare("patchbay", Qt::CaseInsensitive) == 0) + const String& tagName(elem->getTagName()); + + if (tagName.equalsIgnoreCase("patchbay")) { CarlaString sourcePort, targetPort; - for (QDomNode patchNode = node.firstChild(); ! patchNode.isNull(); patchNode = patchNode.nextSibling()) + for (XmlElement* patchElem = elem->getFirstChildElement(); patchElem != nullptr; patchElem = patchElem->getNextElement()) { + const String& patchTag(patchElem->getTagName()); + sourcePort.clear(); targetPort.clear(); - if (patchNode.toElement().tagName().compare("connection", Qt::CaseInsensitive) != 0) + if (! patchTag.equalsIgnoreCase("connection")) continue; - for (QDomNode connNode = patchNode.firstChild(); ! connNode.isNull(); connNode = connNode.nextSibling()) + for (XmlElement* connElem = patchElem->getFirstChildElement(); connElem != nullptr; connElem = connElem->getNextElement()) { - const QString tag(connNode.toElement().tagName()); - const QString text(connNode.toElement().text().trimmed()); + const String& tag(connElem->getTagName()); + const String text(connElem->getAllSubText().trim()); - if (tag.compare("source", Qt::CaseInsensitive) == 0) - sourcePort = text.toUtf8().constData(); - else if (tag.compare("target", Qt::CaseInsensitive) == 0) - targetPort = text.toUtf8().constData(); + if (tag.equalsIgnoreCase("source")) + sourcePort = text.toRawUTF8(); + else if (tag.equalsIgnoreCase("target")) + targetPort = text.toRawUTF8(); } if (sourcePort.isNotEmpty() && targetPort.isNotEmpty()) @@ -1767,12 +1759,7 @@ bool CarlaEngine::saveProject(const char* const filename) CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #3)"); carla_debug("CarlaEngine::saveProject(\"%s\")", filename); - QFile file(filename); - - if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) - return false; - - QTextStream out(&file); + MemoryOutputStream out; out << "\n"; out << "\n"; out << "\n"; @@ -1842,8 +1829,13 @@ bool CarlaEngine::saveProject(const char* const filename) out << "\n"; - file.close(); - return true; + File file(filename); + + if (file.replaceWithData(out.getData(), out.getDataSize())) + return true; + + setLastError("Failed to write file"); + return false; } // ----------------------------------------------------------------------- diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 47f1f8b1c..b61f551d7 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -26,7 +26,7 @@ #include "jackbridge/JackBridge.hpp" #include "jackey.h" -#include +#include "juce_core.h" #ifdef __SSE2_MATH__ # include @@ -34,6 +34,9 @@ #define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" +using juce::String; +using juce::StringArray; + CARLA_BACKEND_START_NAMESPACE #if 0 @@ -1862,11 +1865,11 @@ private: { CARLA_SAFE_ASSERT_RETURN(ourName != nullptr && ourName[0] != '\0',); - QStringList parsedGroups; + StringArray parsedGroups; // add our client first { - parsedGroups.append(QString(ourName)); + parsedGroups.add(String(ourName)); GroupNameToId groupNameToId; groupNameToId.setData(++fUsedGroups.lastId, ourName); @@ -1899,9 +1902,9 @@ private: CARLA_SAFE_ASSERT_CONTINUE(found); - QString qGroupName(groupName.buffer()); + String jGroupName(groupName.buffer()); - if (parsedGroups.contains(qGroupName)) + if (parsedGroups.contains(jGroupName)) { groupId = fUsedGroups.getGroupId(groupName); CARLA_SAFE_ASSERT_CONTINUE(groupId > 0); @@ -1909,7 +1912,7 @@ private: else { groupId = ++fUsedGroups.lastId; - parsedGroups.append(qGroupName); + parsedGroups.add(jGroupName); int pluginId = -1; PatchbayIcon icon = (jackPortFlags & JackPortIsPhysical) ? PATCHBAY_ICON_HARDWARE : PATCHBAY_ICON_APPLICATION; diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 79f6d166b..04a8dee46 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -34,8 +34,13 @@ #include "CarlaExternalUI.hpp" #include "CarlaNative.hpp" -#include -#include +#include "juce_core.h" + +using juce::MemoryOutputStream; +using juce::ScopedPointer; +using juce::String; +using juce::XmlDocument; +using juce::XmlElement; CARLA_BACKEND_START_NAMESPACE @@ -1288,8 +1293,7 @@ protected: char* getState() const { - QString string; - QTextStream out(&string); + MemoryOutputStream out; out << "\n"; out << "\n"; out << "\n"; @@ -1323,30 +1327,32 @@ protected: out << "\n"; - return strdup(string.toUtf8().constData()); + return strdup(out.toString().toRawUTF8()); } void setState(const char* const data) { - QDomDocument xml; - xml.setContent(QString(data)); + const String text(data); + XmlDocument xml(text); - QDomNode xmlNode(xml.documentElement()); + ScopedPointer xmlElement(xml.getDocumentElement(true)); + CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); + CARLA_SAFE_ASSERT_RETURN(xmlElement->getTagName().equalsIgnoreCase("carla-project"),); - if (xmlNode.toElement().tagName().compare("carla-project", Qt::CaseInsensitive) != 0) - { - carla_stderr2("Not a valid Carla project"); - return; - } + // completely load file + xmlElement = xml.getDocumentElement(false); + CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); //bool pluginsAdded = false; - for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling()) + for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) { - if (node.toElement().tagName().compare("plugin", Qt::CaseInsensitive) == 0) + const String& tagName(elem->getTagName()); + + if (tagName.equalsIgnoreCase("plugin")) { StateSave stateSave; - stateSave.fillFromXmlNode(node); + stateSave.fillFromXmlElement(elem); CARLA_SAFE_ASSERT_CONTINUE(stateSave.type != nullptr); diff --git a/source/backend/engine/Makefile b/source/backend/engine/Makefile index 3ad5ea114..796e5e469 100644 --- a/source/backend/engine/Makefile +++ b/source/backend/engine/Makefile @@ -60,7 +60,7 @@ debug: # -------------------------------------------------------------- CarlaEngine.cpp.o: CarlaEngine.cpp $(CARLA_ENGINE_CPP_DEPS) - $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -c -o $@ + $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ CarlaEngineInternal.cpp.o: CarlaEngineInternal.cpp $(CARLA_ENGINE_INTERNAL_CPP_DEPS) $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ @@ -72,7 +72,7 @@ CarlaEngineThread.cpp.o: CarlaEngineThread.cpp $(CARLA_ENGINE_THREAD_CPP_DEPS) $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ CarlaEngineJack.cpp.o: CarlaEngineJack.cpp $(CARLA_ENGINE_JACK_CPP_DEPS) - $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ + $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ CarlaEngineRtAudio.cpp.o: CarlaEngineRtAudio.cpp $(CARLA_ENGINE_RTAUDIO_CPP_DEPS) $(CXX) $< $(BUILD_CXX_FLAGS) $(RTAUDIO_FLAGS) $(RTMIDI_FLAGS) -c -o $@ @@ -81,9 +81,9 @@ CarlaEngineJuce.cpp.o: CarlaEngineJuce.cpp $(CARLA_ENGINE_JUCE_CPP_DEPS) $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ CarlaEngineNative.cpp.o: CarlaEngineNative.cpp $(CARLA_ENGINE_NATIVE_CPP_DEPS) - $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -c -o $@ + $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ CarlaEngineNative.cpp.exp.o: CarlaEngineNative.cpp $(CARLA_ENGINE_NATIVE_CPP_DEPS) - $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -DCARLA_PLUGIN_EXPORT -c -o $@ + $(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_EXPORT -c -o $@ # -------------------------------------------------------------- diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index b1f5823e9..b9955c79e 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -24,9 +24,17 @@ #include -#include -#include -#include +// FIXME +#include + +#include "juce_core.h" + +using juce::File; +using juce::MemoryOutputStream; +using juce::ScopedPointer; +using juce::String; +using juce::XmlDocument; +using juce::XmlElement; CARLA_BACKEND_START_NAMESPACE @@ -856,20 +864,20 @@ bool CarlaPlugin::saveStateToFile(const char* const filename) CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); carla_debug("CarlaPlugin::saveStateToFile(\"%s\")", filename); - QFile file(filename); - - if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) - return false; - - QTextStream out(&file); + MemoryOutputStream out; out << "\n"; out << "\n"; out << "\n"; out << getStateSave().toString(); out << "\n"; - file.close(); - return true; + File file(filename); + + if (file.replaceWithData(out.getData(), out.getDataSize())) + return true; + + pData->engine->setLastError("Failed to write file"); + return false; } bool CarlaPlugin::loadStateFromFile(const char* const filename) @@ -877,25 +885,20 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename) CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); carla_debug("CarlaPlugin::loadStateFromFile(\"%s\")", filename); - QFile file(filename); + File file(filename); + CARLA_SAFE_ASSERT_RETURN(file.existsAsFile(), false); - if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) - return false; + XmlDocument xml(file); + ScopedPointer xmlElement(xml.getDocumentElement(true)); + CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false); + CARLA_SAFE_ASSERT_RETURN(xmlElement->getTagName().equalsIgnoreCase("carla-preset"), false); - QDomDocument xml; - xml.setContent(file.readAll()); - file.close(); + // completely load file + xmlElement = xml.getDocumentElement(false); + CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false); - QDomNode xmlNode(xml.documentElement()); - - if (xmlNode.toElement().tagName().compare("carla-preset", Qt::CaseInsensitive) == 0) - { - pData->engine->setLastError("Not a valid Carla preset file"); - return false; - } - - pData->stateSave.fillFromXmlNode(xmlNode); - loadStateSave(pData->stateSave); + if (pData->stateSave.fillFromXmlElement(xmlElement->getFirstChildElement())) + loadStateSave(pData->stateSave); return true; } @@ -1410,8 +1413,10 @@ void CarlaPlugin::idle() carla_stdout("Trying to get window..."); - QString uiTitle(QString("%1 (GUI)").arg(pData->name)); - if (CarlaPluginUi::tryTransientWinIdMatch(pData->osc.data.target != nullptr ? pData->osc.thread.getPid() : 0, uiTitle.toUtf8().constData(), pData->engine->getOptions().frontendWinId)) + CarlaString uiTitle(pData->name); + uiTitle += " (GUI)"; + + if (CarlaPluginUi::tryTransientWinIdMatch(pData->osc.data.target != nullptr ? pData->osc.thread.getPid() : 0, uiTitle, pData->engine->getOptions().frontendWinId)) pData->transientTryCounter = 0; } diff --git a/source/backend/plugin/Makefile b/source/backend/plugin/Makefile index c7212f9ec..26245d1ba 100644 --- a/source/backend/plugin/Makefile +++ b/source/backend/plugin/Makefile @@ -52,7 +52,7 @@ debug: # -------------------------------------------------------------- CarlaPlugin.cpp.o: CarlaPlugin.cpp $(CARLA_PLUGIN_CPP_DEPS) - $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -c -o $@ + $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ CarlaPluginInternal.cpp.o: CarlaPluginInternal.cpp $(CARLA_PLUGIN_INTERNAL_CPP_DEPS) $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ diff --git a/source/utils/CarlaMutex.hpp b/source/utils/CarlaMutex.hpp index 74ae07fdc..fffaace87 100644 --- a/source/utils/CarlaMutex.hpp +++ b/source/utils/CarlaMutex.hpp @@ -209,9 +209,7 @@ class CarlaScopeTryLocker public: CarlaScopeTryLocker(const Mutex& mutex) noexcept : fMutex(mutex), - fLocked(mutex.tryLock()) - { - } + fLocked(mutex.tryLock()) {} ~CarlaScopeTryLocker() noexcept { diff --git a/source/utils/CarlaRingBuffer.hpp b/source/utils/CarlaRingBuffer.hpp index a28bee1bd..ca01d063c 100644 --- a/source/utils/CarlaRingBuffer.hpp +++ b/source/utils/CarlaRingBuffer.hpp @@ -120,9 +120,7 @@ public: bool isDataAvailableForReading() const noexcept { - CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false); - - return (fBuffer->buf != nullptr && fBuffer->head != fBuffer->tail); + return (fBuffer != nullptr && fBuffer->buf != nullptr && fBuffer->head != fBuffer->tail); } bool isEmpty() const noexcept diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 071d01b3f..cfb23bae9 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -21,11 +21,11 @@ #include "CarlaMathUtils.hpp" #include "CarlaMIDI.h" -#ifdef HAVE_JUCE_LATER -# include "juce_core.h" +#include "juce_core.h" using juce::String; using juce::XmlElement; -#else + +#if 0 # include # include #endif @@ -35,7 +35,6 @@ CARLA_BACKEND_START_NAMESPACE // ----------------------------------------------------------------------- // xmlSafeString -#ifdef HAVE_JUCE_LATER static String xmlSafeString(const String& string, const bool toXml) { String newString(string); @@ -45,7 +44,7 @@ static String xmlSafeString(const String& string, const bool toXml) else return newString.replace("<","<").replace(">",">").replace("'","'").replace(""","\"").replace("&","&"); } -#else +#if 0 static QString xmlSafeString(const QString& string, const bool toXml) { QString newString(string); @@ -60,12 +59,11 @@ static QString xmlSafeString(const QString& string, const bool toXml) // ----------------------------------------------------------------------- // xmlSafeStringCharDup -#ifdef HAVE_JUCE_LATER static const char* xmlSafeStringCharDup(const String& string, const bool toXml) { return carla_strdup(xmlSafeString(string, toXml).toRawUTF8()); } -#else +#if 0 static const char* xmlSafeStringCharDup(const QString& string, const bool toXml) { return carla_strdup(xmlSafeString(string, toXml).toUtf8().constData()); @@ -216,16 +214,15 @@ void StateSave::clear() noexcept // ----------------------------------------------------------------------- // fillFromXmlElement -#ifdef HAVE_JUCE_LATER -void StateSave::fillFromXmlElement(const XmlElement* const xmlElement) +bool StateSave::fillFromXmlElement(const XmlElement* const xmlElement) { - clear(); + CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false); - CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); + clear(); for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) { - String tagName(elem->getTagName()); + const String& tagName(elem->getTagName()); // --------------------------------------------------------------- // Info @@ -404,8 +401,10 @@ void StateSave::fillFromXmlElement(const XmlElement* const xmlElement) } } } + + return true; } -#else +#if 0 void StateSave::fillFromXmlNode(const QDomNode& xmlNode) { clear(); @@ -629,7 +628,6 @@ void StateSave::fillFromXmlNode(const QDomNode& xmlNode) // ----------------------------------------------------------------------- // fillXmlStringFromStateSave -#ifdef HAVE_JUCE_LATER String StateSave::toString() const { String content; @@ -702,15 +700,15 @@ String StateSave::toString() const dataXml << " " << (active ? "Yes" : "No") << "\n"; if (dryWet != 1.0f) - dataXml << " " << dryWet << "\n"; + dataXml << " " << String(dryWet, 7) << "\n"; if (volume != 1.0f) - dataXml << " " << volume << "\n"; + dataXml << " " << String(volume, 7) << "\n"; if (balanceLeft != -1.0f) - dataXml << " " << balanceLeft << "\n"; + dataXml << " " << String(balanceLeft, 7) << "\n"; if (balanceRight != 1.0f) - dataXml << " " << balanceRight << "\n"; + dataXml << " " << String(balanceRight, 7) << "\n"; if (panning != 0.0f) - dataXml << " " << panning << "\n"; + dataXml << " " << String(panning, 7) << "\n"; if (ctrlChannel < 0) dataXml << " N\n"; @@ -733,7 +731,7 @@ String StateSave::toString() const parameterXml << " " << xmlSafeString(stateParameter->symbol, true) << "\n"; if (stateParameter->isInput) - parameterXml << " " << stateParameter->value << "\n"; + parameterXml << " " << String(stateParameter->value, 15) << "\n"; if (stateParameter->midiCC > 0) { @@ -783,7 +781,7 @@ String StateSave::toString() const { customDataXml << " \n"; customDataXml << xmlSafeString(stateCustomData->value, true); - customDataXml << " \n"; + customDataXml << "\n \n"; } else { @@ -809,7 +807,7 @@ String StateSave::toString() const return content; } -#else +#if 0 QString StateSave::toString() const { QString content; diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index 84ca09ca7..d7167697f 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -21,15 +21,10 @@ #include "CarlaBackend.h" #include "LinkedList.hpp" -#ifdef HAVE_JUCE_LATER namespace juce { class String; class XmlElement; } -#else -class QDomNode; -class QString; -#endif // ----------------------------------------------------------------------- @@ -101,17 +96,8 @@ struct StateSave { ~StateSave() noexcept; void clear() noexcept; -#ifdef HAVE_JUCE_LATER - void fillFromXmlElement(const juce::XmlElement* const xmlElement); -#else - void fillFromXmlNode(const QDomNode& xmlNode); -#endif - -#ifdef HAVE_JUCE_LATER + bool fillFromXmlElement(const juce::XmlElement* const xmlElement); juce::String toString() const; -#else - QString toString() const; -#endif CARLA_DECLARE_NON_COPY_STRUCT(StateSave) };