Bug 141956 - Ada code generator is generating "withs" in both directions for dependancies and directional associations
Summary: Ada code generator is generating "withs" in both directions for dependancies ...
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Oliver Kellogg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-20 04:41 UTC by Mark Gardinier
Modified: 2007-02-20 22:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
xmi, generated code for problem (3.04 KB, application/x-bzip2)
2007-02-20 04:46 UTC, Mark Gardinier
Details
bug141956-fix.diff (2.20 KB, patch)
2007-02-20 21:42 UTC, Oliver Kellogg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Gardinier 2007-02-20 04:41:38 UTC
Version:           1.5.61 with patches (using KDE KDE 3.5.5)
Installed from:    Fedora RPMs
Compiler:          n/a 
OS:                Linux

1)  Create two simple classes
2)  Draw a dependancy or directional association between the classes
3)  Generate the ada code.
4)  Note that both specs with each other in.
5)  The class which has the arrow pointing away from it is the only class which should have the "with" in its  
    code.
Comment 1 Mark Gardinier 2007-02-20 04:46:06 UTC
Created attachment 19753 [details]
xmi, generated code for problem
Comment 2 Oliver Kellogg 2007-02-20 21:42:01 UTC
Created attachment 19764 [details]
bug141956-fix.diff

SVN is not letting me commit right now so here is the fix for the impatient.

findObjectsRelated(): Only consider those associations for which `c' is in
 role A. Only add the role B object to the returned list.
Comment 3 Oliver Kellogg 2007-02-20 22:17:44 UTC
SVN commit 635772 by okellogg:

findObjectsRelated(): Only consider those associations for which `c' is in
 role A. Only add the role B object to the returned list.
BUG:141956


 M  +2 -0      ChangeLog  
 M  +4 -10     umbrello/codegenerator.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #635771:635772
@@ -15,6 +15,8 @@
 * Unable to delete multiplicity information or lable from an association
   (141813)
 * C++ code generator does not correctly define namespaces (141876)
+* Ada code generator generates "withs" in both directions for certain
+  associations (141956)
 
 Version 1.5.61
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerator.cpp #635771:635772
@@ -548,7 +548,6 @@
 
 void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList) {
     UMLPackage *temp;
-    UMLDoc *umldoc = UMLApp::app()->getDocument();
     UMLAssociationList associations = c->getAssociations();
 
     for (UMLAssociation *a = associations.first(); a; a = associations.next()) {
@@ -568,10 +567,8 @@
             {
                 UMLObject *objA = a->getObject(Uml::A);
                 UMLObject *objB = a->getObject(Uml::B);
-                if (objA != c)
-                    temp = (UMLPackage*)objA;
-                else if (objB != c)
-                    temp = (UMLPackage*)objB;
+                if (objA == c)
+                    temp = static_cast<UMLPackage*>(objB);
             }
             break;
         case Uml::at_Aggregation:
@@ -582,12 +579,9 @@
                 UMLObject *objA = a->getObject(Uml::A);
                 UMLObject *objB = a->getObject(Uml::B);
                 // Add related object only if the rolename is not empty.
-                if (objA != c && !a->getRoleName(Uml::A).isEmpty() &&
-                    objA->getBaseType() != Uml::ot_Datatype)
-                    temp = (UMLPackage*)objA;
-                else if (objB != c && !a->getRoleName(Uml::B).isEmpty() &&
+                if (objA == c && !a->getRoleName(Uml::B).isEmpty() &&
                     objB->getBaseType() != Uml::ot_Datatype)
-                    temp = (UMLPackage*)objB;
+                    temp = static_cast<UMLPackage*>(objB);
             }
             break;
         default: /* all others.. like for state diagrams..we currently don't use */