[Uml-devel] KDE/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sun Mar 4 11:52:46 UTC 2012
SVN commit 1283458 by okellogg:
umbrello/umlcanvasobject.cpp
- removeAssociationEnd(): Call UMLDoc:removeAssociation() on the assoc.
umbrello/umldoc.cpp
- removeUMLObject(): Remove associations that this object may participate in.
BUG: 293042
M +5 -4 umlcanvasobject.cpp
M +31 -0 umldoc.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/umlcanvasobject.cpp #1283457:1283458
@@ -13,6 +13,7 @@
// local includes
#include "debug_utils.h"
+#include "model_utils.h"
#include "uml.h"
#include "umldoc.h"
#include "classifier.h"
@@ -101,11 +102,10 @@
*/
bool UMLCanvasObject::hasAssociation(UMLAssociation* assoc)
{
- if (m_List.count(assoc) > 0) {
- return true;
+ uint cnt = m_List.count(assoc);
+ uDebug() << "count is " << cnt;
+ return (cnt > 0);
}
- return false;
-}
/**
* Remove an association end from the CanvasObject.
@@ -119,6 +119,7 @@
uDebug() << "can not find given assoc " << assoc << " in list";
return -1;
}
+ UMLApp::app()->document()->removeAssociation(assoc, false);
UMLObject::emitModified();
emit sigAssociationEndRemoved(assoc);
return m_List.count();
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #1283457:1283458
@@ -1523,6 +1523,10 @@
*/
void UMLDoc::removeUMLObject(UMLObject* umlobject)
{
+ if (umlobject == NULL) {
+ uError() << "called with NULL parameter";
+ return;
+ }
UMLApp::app()->docWindow()->updateDocumentation(true);
UMLObject::ObjectType type = umlobject->baseType();
@@ -1567,6 +1571,33 @@
} else {
UMLPackage* pkg = umlobject->umlPackage();
if (pkg) {
+ // Remove associations that this object may participate in.
+ UMLCanvasObject *c = dynamic_cast<UMLCanvasObject*>(umlobject);
+ if (c) {
+ // In the current implementation, all associations live in the
+ // root folder.
+ UMLPackage* rootPkg = Model_Utils::rootPackage(c);
+ if (rootPkg == NULL) {
+ uError() << umlobject->name() << ": root package is not set !";
+ return;
+ }
+ UMLObjectList rootObjects = rootPkg->containedObjects();
+ // Store the associations to remove in a buffer because we
+ // should not remove elements from m_objectList while it is
+ // being iterated over.
+ UMLAssociationList assocsToRemove;
+ foreach (UMLObject *obj , rootObjects) {
+ if (obj->baseType() == UMLObject::ot_Association) {
+ UMLAssociation *assoc = static_cast<UMLAssociation*>(obj);
+ if (c->hasAssociation(assoc)) {
+ assocsToRemove.append(assoc);
+ }
+ }
+ }
+ foreach (UMLAssociation *a, assocsToRemove) {
+ removeAssociation(a, false);
+ }
+ }
pkg->removeObject(umlobject);
} else {
uError() << umlobject->name() << ": parent package is not set !";
More information about the umbrello-devel
mailing list