Handle some midnam edge-cases
authorRobin Gareus <robin@gareus.org>
Fri, 23 Nov 2018 21:43:26 +0000 (22:43 +0100)
committerRobin Gareus <robin@gareus.org>
Fri, 23 Nov 2018 21:43:26 +0000 (22:43 +0100)
Whitespace between XML nodes can result in "text" children.
Those need to be skipped in the patch-name list.

libs/midi++2/midnam_patch.cc

index af81dba0e0c417776541d086bd8171169575caee..71c82d78fdbc56a08c5d05473956563c8280558b 100644 (file)
@@ -113,7 +113,7 @@ int
 Patch::set_state (const XMLTree& tree, const XMLNode& node)
 {
        if (node.name() != "Patch") {
-               cerr << "Incorrect node " << node.name() << " handed to Patch" << endl;
+               cerr << "Incorrect node type '" << node.name() << "' handed to Patch" << endl;
                return -1;
        }
 
@@ -437,8 +437,9 @@ PatchBank::set_state (const XMLTree& tree, const XMLNode& node)
                const XMLNodeList patches = patch_name_list->children();
                for (XMLNodeList::const_iterator i = patches.begin(); i != patches.end(); ++i) {
                        boost::shared_ptr<Patch> patch (new Patch (string(), 0, _number));
-                       patch->set_state(tree, *(*i));
-                       _patch_name_list.push_back(patch);
+                       if (0 == patch->set_state(tree, *(*i))) {
+                               _patch_name_list.push_back(patch);
+                       }
                }
        } else {
                XMLNode* use_patch_name_list = node.child ("UsesPatchNameList");