summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-14 19:52:19 +0000
committerDavid Robillard <d@drobilla.net>2010-12-14 19:52:19 +0000
commit2cfd996c38fefef9052c12758d681cba7be0642e (patch)
tree205d3817e64ca80e2c9a5b3d1519a0943ec95d52
parent88e6b341cb0b7c2023d6baa75f85eb58ebcaedd0 (diff)
downloadingen-2cfd996c38fefef9052c12758d681cba7be0642e.tar.gz
ingen-2cfd996c38fefef9052c12758d681cba7be0642e.tar.bz2
ingen-2cfd996c38fefef9052c12758d681cba7be0642e.zip
Apply patch from larsl to tolerate broken LV2 class hierarchies (ticket #529).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2682 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/gui/PatchCanvas.cpp18
-rw-r--r--src/gui/PatchCanvas.hpp4
2 files changed, 17 insertions, 5 deletions
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 1b6defc6..ca63df6f 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -183,8 +183,10 @@ PatchCanvas::build_menus()
* @a plugin class into @a menu
*/
size_t
-PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
- SLV2PluginClass plugin_class, SLV2PluginClasses classes, const LV2Children& children)
+PatchCanvas::build_plugin_class_menu(
+ Gtk::Menu* menu,
+ SLV2PluginClass plugin_class, SLV2PluginClasses classes, const LV2Children& children,
+ std::set<const char*>& ancestors)
{
size_t num_items = 0;
SLV2Value class_uri = slv2_plugin_class_get_uri(plugin_class);
@@ -197,10 +199,16 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
return 0;
// Add submenus
+ ancestors.insert(class_uri_str);
for (LV2Children::const_iterator i = kids.first; i != kids.second; ++i) {
SLV2PluginClass c = i->second;
const char* sub_label_str = slv2_value_as_string(slv2_plugin_class_get_label(c));
const char* sub_uri_str = slv2_value_as_string(slv2_plugin_class_get_uri(c));
+ if (ancestors.find(sub_uri_str) != ancestors.end()) {
+ LOG(warn) << "Infinite LV2 class recursion: " << class_uri_str
+ << " <: " << sub_uri_str << endl;
+ return 0;
+ }
Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem(sub_label_str);
menu->items().push_back(menu_elem);
@@ -209,7 +217,7 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu());
menu_item->set_submenu(*submenu);
- size_t num_child_items = build_plugin_class_menu(submenu, c, classes, children);
+ size_t num_child_items = build_plugin_class_menu(submenu, c, classes, children, ancestors);
_class_menus.insert(make_pair(sub_uri_str, MenuRecord(menu_item, submenu)));
if (num_child_items == 0)
@@ -217,6 +225,7 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
++num_items;
}
+ ancestors.erase(class_uri_str);
return num_items;
}
@@ -248,7 +257,8 @@ PatchCanvas::build_plugin_menu()
p = slv2_plugin_class_get_uri(lv2_plugin);
children.insert(make_pair(slv2_value_as_string(p), c));
}
- build_plugin_class_menu(_plugin_menu, lv2_plugin, classes, children);
+ std::set<const char*> ancestors;
+ build_plugin_class_menu(_plugin_menu, lv2_plugin, classes, children, ancestors);
}
#endif
diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp
index ae99c1c1..aa27c9e1 100644
--- a/src/gui/PatchCanvas.hpp
+++ b/src/gui/PatchCanvas.hpp
@@ -20,6 +20,7 @@
#include <string>
#include <map>
+#include <set>
#include <boost/shared_ptr.hpp>
#include "ingen-config.h"
#include "flowcanvas/Canvas.hpp"
@@ -116,7 +117,8 @@ private:
Gtk::Menu* menu,
SLV2PluginClass plugin_class,
SLV2PluginClasses classes,
- const LV2Children& children);
+ const LV2Children& children,
+ std::set<const char*>& ancestors);
#endif
GraphObject::Properties get_initial_data();