[Uml-devel] [Bug 100142] associations with deleted classes persist in saved file

Oliver Kellogg okellogg at users.sourceforge.net
Fri Feb 25 09:46:10 UTC 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=100142         
okellogg users sourceforge net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From okellogg users sourceforge net  2005-02-25 18:41 -------
CVS commit by okellogg: 

BUG:100142 - UMLCanvasObject::removeAllAssociations(): New.


  M +1 -1      ChangeLog   1.69
  M +21 -0     umbrello/umlcanvasobject.cpp   1.33
  M +5 -0      umbrello/umlcanvasobject.h   1.22
  M +12 -0     umbrello/umllistview.cpp   1.147


--- kdesdk/umbrello/ChangeLog  #1.68:1.69
 @ -29,5 +29,5  @
 94728 94795 94883 95082 95247 95252 95722 95924 95951 95954
 96216 96221 96964 97155 97182 97697 97887 97984 98603 98899
-99697
+ 99697 100142
 
 Version 1.3

--- kdesdk/umbrello/umbrello/umlcanvasobject.cpp  #1.32:1.33
 @ -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 */ ) {

--- kdesdk/umbrello/umbrello/umlcanvasobject.h  #1.21:1.22
 @ -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/umllistview.cpp  #1.146:1.147
 @ -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"




More information about the umbrello-devel mailing list