From 433b5c46520b16882cb2a79f9d44840037ec914d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 24 Jun 2007 16:01:26 +0000 Subject: Fixed unnnecessary name mangling of deprecated patches. git-svn-id: http://svn.drobilla.net/lad/ingen@541 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/DeprecatedLoader.cpp | 36 ++++++++++++++++++++++++------------ src/libs/client/DeprecatedLoader.h | 1 + src/libs/client/client.cpp | 1 - src/libs/client/client.h | 3 +++ 4 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index d4b650df..3c95d9ac 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -97,12 +97,26 @@ DeprecatedLoader::find_file(const string& filename, const string& additional_pat #endif +string +DeprecatedLoader::nameify_if_invalid(const string& name) +{ + if (Path::is_valid_name(name)) { + return name; + } else { + const string new_name = Path::nameify(name); + cerr << "WARNING: Illegal name '" << name << "' converted to '" << name << "'" << endl; + return new_name; + } +} + + string DeprecatedLoader::translate_load_path(const string& path) { std::map::iterator t = _load_path_translations.find(path); if (t != _load_path_translations.end()) { + assert(Path::is_valid((*t).second)); return (*t).second; } else { assert(Path::is_valid(path)); @@ -217,7 +231,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, if (load_name) { assert(key != NULL); if (parent_path) - path = Path(parent_path.get()).base() + Path::nameify((char*)key); + path = Path(parent_path.get()).base() + nameify_if_invalid((char*)key); else path = Path("/"); } @@ -333,9 +347,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) { - cerr << "NAME: " << (char*)key; - path = parent.base() + Path::nameify((char*)key); - cerr << ", PATH: " << path << endl; + path = parent.base() + nameify_if_invalid((char*)key); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphonic"))) { polyphonic = !strcmp((char*)key, "true"); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"type"))) { @@ -359,7 +371,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr key = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); if ((!xmlStrcmp(child->name, (const xmlChar*)"name"))) { - port_name = Path::nameify((char*)key); + port_name = nameify_if_invalid((char*)key); } else if ((!xmlStrcmp(child->name, (const xmlChar*)"user-min"))) { user_min = atof((char*)key); } else if ((!xmlStrcmp(child->name, (const xmlChar*)"user-max"))) { @@ -480,7 +492,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr if (is_port) { const string old_path = path; - const string new_path = Path::pathify(old_path); + const string new_path = (Path::is_valid(old_path) ? old_path : Path::pathify(old_path)); // Set up translations (for connections etc) to alias both the old // module path and the old module/port path to the new port path @@ -607,10 +619,10 @@ DeprecatedLoader::load_connection(const Path& parent, xmlDocPtr doc, const xmlNo } // Compatibility fixes for old (fundamentally broken) patches - source_node = Path::nameify(source_node); - source_port = Path::nameify(source_port); - dest_node = Path::nameify(dest_node); - dest_port = Path::nameify(dest_port); + source_node = nameify_if_invalid(source_node); + source_port = nameify_if_invalid(source_port); + dest_node = nameify_if_invalid(dest_node); + dest_port = nameify_if_invalid(dest_port); _engine->connect( translate_load_path(parent.base() + source_node +"/"+ source_port), @@ -662,8 +674,8 @@ DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePt } // Compatibility fixes for old patch files - node_name = Path::nameify(node_name); - port_name = Path::nameify(port_name); + node_name = nameify_if_invalid(node_name); + port_name = nameify_if_invalid(port_name); if (port_name == "") { string msg = "Unable to parse control in patch file ( node = "; diff --git a/src/libs/client/DeprecatedLoader.h b/src/libs/client/DeprecatedLoader.h index dde9f631..1bf81c9d 100644 --- a/src/libs/client/DeprecatedLoader.h +++ b/src/libs/client/DeprecatedLoader.h @@ -70,6 +70,7 @@ public: private: void add_metadata(MetadataMap& data, string key, string value); + string nameify_if_invalid(const string& name); string translate_load_path(const string& path); //string _patch_search_path; diff --git a/src/libs/client/client.cpp b/src/libs/client/client.cpp index 99fa116c..da28a342 100644 --- a/src/libs/client/client.cpp +++ b/src/libs/client/client.cpp @@ -30,7 +30,6 @@ new_osc_interface(const std::string& url) return SharedPtr(oes); } - } // namespace Client } // namespace Ingen diff --git a/src/libs/client/client.h b/src/libs/client/client.h index c2b19d12..fa4ad6c9 100644 --- a/src/libs/client/client.h +++ b/src/libs/client/client.h @@ -22,6 +22,8 @@ namespace Ingen { +class Engine; + namespace Shared { class EngineInterface; } namespace Client { @@ -29,6 +31,7 @@ namespace Client { extern "C" { SharedPtr new_osc_interface(const std::string& url); + SharedPtr new_queued_interface(SharedPtr engine); } -- cgit v1.2.1