[Uml-devel] KDE_3_4_BRANCH: kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Feb 26 03:25:03 UTC 2005
CVS commit by okellogg:
Backport following fix from HEAD:
CVS commit by okellogg:
BUG:100142 - UMLCanvasObject::removeAllAssociations(): New.
M +21 -0 umlcanvasobject.cpp 1.32.2.1
M +5 -0 umlcanvasobject.h 1.21.2.1
M +12 -0 umllistview.cpp 1.146.2.1
--- kdesdk/umbrello/umbrello/umllistview.cpp #1.146:1.146.2.1
@@ -377,4 +377,16 @@ void UMLListView::popupMenuSel(int sel)
}
m_doc->removeUMLObject(object);
+ UMLCanvasObject *canvasObj = dynamic_cast<UMLCanvasObject*>(object);
+ if (canvasObj) {
+ /**
+ * We cannot just delete canvasObj here: What if the object
+ * is still being used by others (for example, as a parameter
+ * or return type of an operation) ?
+ * Deletion should not have been permitted in the first place
+ * if the object still has users - but Umbrello is lacking
+ * that logic.
+ */
+ canvasObj->removeAllAssociations();
+ }
} else {
kdWarning() << "umllistview::listpopupmenu::mt_Delete called with unknown type"
--- kdesdk/umbrello/umbrello/umlcanvasobject.h #1.21:1.21.2.1
@@ -87,4 +87,9 @@ public:
/**
+ * Remove all associations from the CanvasObject.
+ */
+ void removeAllAssociations();
+
+ /**
* Returns the number of associations for the CanvasObject.
* This is the sum of the aggregations and compositions.
--- kdesdk/umbrello/umbrello/umlcanvasobject.cpp #1.32:1.32.2.1
@@ -7,4 +7,5 @@
* *
***************************************************************************/
+#include "uml.h"
#include "umldoc.h"
#include "umlcanvasobject.h"
@@ -27,4 +28,5 @@ UMLCanvasObject::UMLCanvasObject(const Q
////////////////////////////////////////////////////////////////////////////////////////////////////
UMLCanvasObject::~UMLCanvasObject() {
+ removeAllAssociations();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -67,4 +69,23 @@ int UMLCanvasObject::removeAssociation(U
}
+void UMLCanvasObject::removeAllAssociations() {
+ UMLDoc *umldoc = UMLApp::app()->getDocument();
+ for (UMLAssociationListIt ait(m_AssocsList); ait.current(); ++ait) {
+ UMLAssociation *assoc = ait.current();
+ umldoc->slotRemoveUMLObject(assoc);
+ UMLCanvasObject *other = NULL;
+ UMLObject* objA = assoc->getObject(Uml::A);
+ UMLObject* objB = assoc->getObject(Uml::B);
+ if (objA == this)
+ other = dynamic_cast<UMLCanvasObject*>(objA);
+ else
+ other = dynamic_cast<UMLCanvasObject*>(objB);
+ if (other)
+ other->removeAssociation(assoc);
+ delete assoc;
+ }
+ m_AssocsList.clear();
+}
+
QString UMLCanvasObject::uniqChildName( const Uml::Object_Type type,
bool seekStereo /* = false */ ) {
More information about the umbrello-devel
mailing list