Commit b391fe5d authored by Ralf Habacker's avatar Ralf Habacker

Fix 'Umbrello crashes after undoing class attribute deletion'.

UMLClassifierListItem objects were not be added to the parent
on undo.

Also keep handling of UMLAttribute instances in sync with
UMLOperation and UMLTemplate which are only removed from the
parent classifier and not deleted.

BUG:372601
FIXED-IN:2.20.80 (KDE Applications 16.11.80)
parent e56248b5
......@@ -1117,10 +1117,8 @@ UMLClassifier* UMLDoc::findUMLClassifier(const QString &name)
*/
bool UMLDoc::addUMLObject(UMLObject* object)
{
UMLObject::ObjectType ot = object->baseType();
if (ot == UMLObject::ot_Attribute || ot == UMLObject::ot_Operation || ot == UMLObject::ot_EnumLiteral
|| ot == UMLObject::ot_EntityAttribute || ot == UMLObject::ot_Template || ot == UMLObject::ot_Stereotype) {
DEBUG(DBG_SRC) << object->name() << ": not adding type " << ot;
if (object->isUMLStereotype()) {
DEBUG(DBG_SRC) << object->name() << ": not adding type " << object->baseTypeStr();
return false;
}
UMLPackage *pkg = object->umlPackage();
......@@ -1131,6 +1129,13 @@ bool UMLDoc::addUMLObject(UMLObject* object)
object->setUMLPackage(pkg);
}
// FIXME restore stereotype
UMLClassifierListItem *c = object->asUMLClassifierListItem();
if (c) {
if (!pkg->subordinates().contains(c))
pkg->subordinates().append(c);
return true;
}
return pkg->addObject(object);
}
......
......@@ -889,12 +889,10 @@ int UMLClassifier::removeAttribute(UMLAttribute* att)
uDebug() << "cannot find att given in list";
return -1;
}
// note that we don't delete the attribute, just remove it from the Classifier
disconnect(att, SIGNAL(modified()), this, SIGNAL(modified()));
emit attributeRemoved(att);
UMLObject::emitModified();
// If we are deleting the object, then we don't need to disconnect..this is done auto-magically
// for us by QObject. -b.t.
// disconnect(att, SIGNAL(modified()), this, SIGNAL(modified()));
delete att;
return m_List.count();
}
......
......@@ -77,7 +77,7 @@ public:
virtual void removeAllChildObjects();
UMLObjectList subordinates() const {
UMLObjectList &subordinates() {
return m_List;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment