Bug 100142 - associations with deleted classes persist in saved file
Summary: associations with deleted classes persist in saved file
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: NetBSD pkgsrc NetBSD
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-24 05:44 UTC by Marko Schuetz Schmuck
Modified: 2005-02-25 18:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
bug100142-fix.diff (3.51 KB, patch)
2005-02-25 06:29 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marko Schuetz Schmuck 2005-02-24 05:44:58 UTC
Version:           1.4.0beta2 (using KDE KDE 3.3.2)
Installed from:    NetBSD pkgsrc
OS:                NetBSD

create a diagram with some classes and associations. select the classes and delete them. save the file. look at xmi file produced: it contains associations.
Comment 1 Oliver Kellogg 2005-02-24 20:21:28 UTC
You say "Select the classes and delete them".
Do you mean in the diagram area or the list view?
When I delete classes in the list view, the associations
are no longer in the XMI file.
Comment 2 Oliver Kellogg 2005-02-24 20:52:03 UTC
Whoops, forget the previous comment. I do see the problem now.
Comment 3 Oliver Kellogg 2005-02-25 06:29:07 UTC
Created attachment 9827 [details]
bug100142-fix.diff

I plan to commit this as soon as we leave cvs freeze.
Jon: Is this important enough to move the KDE_3_4_RELEASE tag?
Comment 4 Oliver Kellogg 2005-02-25 18:41:32 UTC
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"