[Uml-devel] KDE_3_2_BRANCH: kdesdk/umbrello/umbrello

Jonathan Riddell jri at jriddell.org
Sat Feb 28 06:46:01 UTC 2004


CVS commit by jriddell: 

backport fix from 27 Feb
--

CVS commit by thomas:

Fix bug : 72615 : associations sometimes reverse because the
constuctor for the association widget was querying for any existing
associations that matched the one attempting to be created. IF one was
already present (such as when one tries to make more than one
aggregation between 2 classes) then it would try to swap the direction
of the association. Failing this, umlview would see that an
association already existed, and then prohibit adding the association
(correctly) but would then leave the object undeleted (incorrect). To
the extent that I have been able to test this patch, it works well,
however, more serious testing is needed to insure that this doesnt
generate new bugs elsewhere. It would be good if Oliver could review
this patch, and confer with me (bt) about what further steps are
needed.


  M +11 -5     associationwidget.cpp   1.80.2.4
  M +5 -4      umlview.cpp   1.119.2.2


--- kdesdk/umbrello/umbrello/associationwidget.cpp  #1.80.2.3:1.80.2.4
@@ -52,10 +52,15 @@ AssociationWidget::AssociationWidget(UML
                 UMLObject* umlRoleB = pWidgetB->getUMLObject();
                 if (umlRoleA != NULL && umlRoleB != NULL) {
-                        bool swap;
-                        // m_pAssociation = umldoc->findAssociation( assocType, umlRoleA, umlRoleB, &swap );
-                        UMLAssociation * myAssoc = umldoc->findAssociation( assocType, umlRoleA, umlRoleB, &swap );
-                        if (myAssoc == NULL) {
-                                myAssoc = new UMLAssociation( umldoc, assocType, umlRoleA, umlRoleB );
+//                      bool swap;
+
+                        // THis isnt correct. We could very easily have more than one
+                        // of the same type of association between the same two objects.
+                        // Just create the association. This search should have been
+                        // done BEFORE creation of the widget, if it mattered to the code.
+//                      UMLAssociation * myAssoc = umldoc->findAssociation( assocType, umlRoleA, umlRoleB, &swap );
+//                      if (myAssoc == NULL) {
+                                UMLAssociation * myAssoc = new UMLAssociation( umldoc, assocType, umlRoleA, umlRoleB );
                                 setUMLAssociation(myAssoc);
+/*
                         } else if (swap) {
                                 kdDebug() << "AssociationWidget(): umldoc->findAssoc returns swap true "
@@ -69,4 +74,5 @@ AssociationWidget::AssociationWidget(UML
                         }
                         setUMLAssociation(myAssoc);
+*/
 /*
                         connect(m_pAssociation, SIGNAL(modified()), this,

--- kdesdk/umbrello/umbrello/umlview.cpp  #1.119.2.1:1.119.2.2
@@ -1943,6 +1943,8 @@ void UMLView::addAssocInViewAndDoc(Assoc
                 // if view went ok, then append in document
                 getDocument() -> addAssociation (a->getAssociation());
-        } else
-                kdError() << "cannot addAssocInViewAndDoc()" << endl;
+        } else { 
+                kdError() << "cannot addAssocInViewAndDoc(), deleting" << endl;
+                delete a;
+        }
 
 }
@@ -3416,5 +3418,4 @@ bool UMLView::loadAssociationsFromXMI( Q
                                           << assoc << ", bad XMI file? Deleting from umlview."
                                           << endl;
-//                              assoc->cleanup();
                                 delete assoc;
                                 /* return false;
@@ -3425,5 +3426,5 @@ bool UMLView::loadAssociationsFromXMI( Q
                                 if(!addAssociation(assoc, false))
                                 {
-                                        kdError()<<"COULDNT addAssociation("<<assoc<<") to umlview, deleting."<<endl;
+                                        kdError()<<"Couldnt addAssociation("<<assoc<<") to umlview, deleting."<<endl;
 //                                      assoc->cleanup();
                                         delete assoc;






More information about the umbrello-devel mailing list