[Uml-devel] kdesdk/umbrello/umbrello

Brian Thomas thomas at mail630.gsfc.nasa.gov
Fri Feb 27 08:25:05 UTC 2004


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.84
  M +5 -4      umlview.cpp   1.123


--- kdesdk/umbrello/umbrello/associationwidget.cpp  #1.83:1.84
@@ -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.122:1.123
@@ -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;
+        }
 
 }
@@ -3417,5 +3419,4 @@ bool UMLView::loadAssociationsFromXMI( Q
                                           << assoc << ", bad XMI file? Deleting from umlview."
                                           << endl;
-//                              assoc->cleanup();
                                 delete assoc;
                                 /* return false;
@@ -3426,5 +3427,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