[Uml-devel] kdesdk/umbrello/umbrello

Brian Thomas thomas at mail630.gsfc.nasa.gov
Thu Nov 13 12:18:26 UTC 2003


CVS commit by thomas: 

bug fix: association allowedAssociations between 2 widgets had short-cutted out full checking of code. The result was that you could have more than one realization between an interface and a class (shouldnt be possible), as well as other problems. In some situations (like loading associations) we dont need the full check (or its inappropriate), but in others, such as creating new associations, or paste operations, we DO want to insure the full check is made.


  M +9 -5      assocrules.cpp   1.19
  M +1 -1      assocrules.h   1.6
  M +1 -1      umlview.cpp   1.115


--- kdesdk/umbrello/umbrello/assocrules.h  #1.5:1.6
@@ -49,5 +49,5 @@ public:
          * This method is used to finish an association.
          */
-        static bool allowAssociation( Association_Type assocType, UMLWidget * widgetA, UMLWidget * widgetB );
+        static bool allowAssociation( Association_Type assocType, UMLWidget * widgetA, UMLWidget * widgetB, bool extendedCheck = true );
 
         /**

--- kdesdk/umbrello/umbrello/assocrules.cpp  #1.18:1.19
@@ -58,8 +56,8 @@ bool AssocRules::allowAssociation( Assoc
 
                 case at_Generalization://can have many sub/super types
-                case at_Realization:
                         return true;
                         break;
 
+                case at_Realization:
                 case at_Implementation://one connected to widget only (a or b)
                         while( ( assoc = it.current() ) ) {
@@ -90,5 +88,7 @@ bool AssocRules::allowAssociation( Assoc
 }
 
-bool AssocRules::allowAssociation( Association_Type assocType, UMLWidget * widgetA, UMLWidget * widgetB ) {
+// when we know what we are going to connect both ends of the association to, we can 
+// use this method.
+bool AssocRules::allowAssociation( Association_Type assocType, UMLWidget * widgetA, UMLWidget * widgetB , bool extendedCheck) {
         UMLWidget_Type widgetTypeA = widgetA -> getBaseType();
         UMLWidget_Type widgetTypeB = widgetB -> getBaseType();
@@ -103,5 +103,9 @@ bool AssocRules::allowAssociation( Assoc
                 }
         }
+        // we can bail here for quick checks, as occur in loading files
+        // for paste or regular creation operations, we need to go further
+        if(!extendedCheck)
         return bValid;
+
         if (!bValid) {
                 return false;

--- kdesdk/umbrello/umbrello/umlview.cpp  #1.114:1.115
@@ -1861,5 +1861,5 @@ bool UMLView::addAssociation( Associatio
 
         //make sure valid
-        if( !AssocRules::allowAssociation( pAssoc->getAssocType(), m_pWidgetA, m_pWidgetB ) ) {
+        if( !AssocRules::allowAssociation( pAssoc->getAssocType(), m_pWidgetA, m_pWidgetB, isPasteOperation ) ) {
                 kdDebug() << "UMLView::addAssociation: allowAssociation returns false "
                           << "for AssocType " << pAssoc->getAssocType() << endl;






More information about the umbrello-devel mailing list