diff --git a/doc/ChangeLog b/doc/ChangeLog index c1bcfd581..73a6a3cf0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,10 @@ +2011-07-09 vadim + + * ObjectManipulator.cpp (addSubinterfaceSubmenu): see #2562 "Crash + when making an interface that has subinterfaces a subinterface of + another interfrace". If an interface has subinterfaces, it should + not be allowed to become subinterface of another interface. + 2011-07-08 vadim * ObjectManipulator_slots.cpp (makeSubinterface): see #2561 "Add diff --git a/src/libgui/ObjectManipulator.cpp b/src/libgui/ObjectManipulator.cpp index 545585bd1..9c35b487d 100644 --- a/src/libgui/ObjectManipulator.cpp +++ b/src/libgui/ObjectManipulator.cpp @@ -896,21 +896,29 @@ void ObjectManipulator::addSubinterfaceSubmenu( const list &top_level_interfaces) { QMenu *submenu = menu->addMenu( tr("Make subinterface of...")); + + int submenu_items_counter = 0; list::const_iterator it; for (it=top_level_interfaces.begin(); it!=top_level_interfaces.end(); ++it) { Interface *intf = Interface::cast(*it); - bool skip_selected_interface = false; + bool skip_interface = false; foreach(FWObject *obj, getCurrentObjectTree()->getSelectedObjects()) { if (obj == intf) { - skip_selected_interface = true; + skip_interface = true; + break; + } + + if (!intf->validateChild(obj)) + { + skip_interface = true; break; } } - if (skip_selected_interface) continue; + if (skip_interface) continue; if (intf->isLoopback()) continue; // can not add interfaces to a read-only parent interface @@ -931,7 +939,11 @@ void ObjectManipulator::addSubinterfaceSubmenu( connect( submenu, SIGNAL(triggered(QAction*)), this, SLOT(makeSubinterface(QAction*))); + + submenu_items_counter++; } + + submenu->setEnabled(submenu_items_counter != 0); } bool ObjectManipulator::getDeleteMenuState(FWObject *obj)