<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>135527</bug_id>
          
          <creation_ts>2006-10-12 19:52:55 +0000</creation_ts>
          <short_desc>Javascript wrong Code Generation</short_desc>
          <delta_ts>2007-02-16 19:37:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>umbrello</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="ediaz666@gmail.com">ediaz666</reporter>
          <assigned_to name="Umbrello Development Group">umbrello-devel</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>476397</commentid>
    <comment_count>0</comment_count>
    <who name="ediaz666@gmail.com">ediaz666</who>
    <bug_when>2006-10-12 19:52:55 +0000</bug_when>
    <thetext>Version:           1.5.5 (using KDE 3.5.5 &quot;release 19.1&quot; , openSUSE )
Compiler:          Target: x86_64-suse-linux
OS:                Linux (x86_64) release 2.6.16.13-4-default

Hi again
I generate javascript code and the result was not good: When you create a composition between class A and class B, the generator returns this:
  function A() {
    ....
    this.m_B = new B();
    ....
  }

  function B() {
    ....
    this.m_A = new A();
    ....
  }
 and it was suppose to instance only class B in class A.
 It also returns a lot of instance of class A itself:

  function A() {
   ...
   this.m_B = new B();
   this.m_B = new B();
   this.m_A = new A();
   this.m_B = new B();
   this.m_B = new B();
   this.m_A = new A();
   ...
  }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>509447</commentid>
    <comment_count>1</comment_count>
    <who name="Antoine Dopffer">compudop</who>
    <bug_when>2007-02-15 22:54:26 +0000</bug_when>
    <thetext>I can&apos;t exactly reproduce this bug in version 1.5.6.
Here is what I get:
Given a class A and a class B, I draw a composition between A and B
----         ------
| A | &lt;&gt;-----|  B  |
-----        ------- 
The generated javascript code is
File A.js:
----------------------------------
**
  * class A
  */

A = function ()
{
  this._init ();
}


/**
 * _init sets all A attributes to their default value. Make sure to call this
 * method within your class constructor
 */
A.prototype._init = function ()
{

  /**Aggregations: */

  /**Compositions: */
  this.m_A = new A ();

}
-----------------------

File B.js:

-----------------------
**
  * class A
  */

A = function ()
{
  this._init ();
}


/**
 * _init sets all A attributes to their default value. Make sure to call this
 * method within your class constructor
 */
A.prototype._init = function ()
{

  /**Aggregations: */

  /**Compositions: */
  this.m_A = new A ();

}
--------------------------------

According to me, there are two errors:
1) There shouldn&apos;t be a composant m_A in class B but a composant m_B in class A (In this case, the C++ generated code doesn&apos;t generate any composants in any classes. The C++ generated code generates a composant m_B if only I add a attribute of class B in class A)
2) There shouldn&apos;t be a composant m_A in class A. In my example, there is only one composant m_A in class A. That&apos;s better than many  but still incorrect

PS : The generated code is identical in trunk</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>509576</commentid>
    <comment_count>2</comment_count>
    <who name="Oliver Kellogg">okellogg</who>
    <bug_when>2007-02-16 19:37:06 +0000</bug_when>
    <thetext>SVN commit 634263 by okellogg:

writeClass (aggregations, compositions): Do not generate code when `c´ is at role B.
 Generate code for the role B object.
BUG:135527


 M  +1 -0      ChangeLog  
 M  +10 -4     umbrello/codegenerators/jswriter.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #634262:634263
@@ -3,6 +3,7 @@
 * Bugs fixed from http://bugs.kde.org:
 * %date% and %time% not being parsed (96612)
 * Relationships for entities do not live outside of an entity relationship diagram (125146)
+* Javascript wrong Code Generation (135527)
 * Javascript Code Generation creates bad format methods (135540)
 * Crash when deleting the link between a package and a class (141602)
 * Ada95 Code Generation Errors for Aggregation (141644)
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/jswriter.cpp #634262:634263
@@ -155,8 +155,11 @@
         js &lt;&lt; m_endl &lt;&lt; m_indentation &lt;&lt; &quot;/**Aggregations: */&quot; &lt;&lt; m_endl;
         for (UMLAssociation* a = aggregations.first(); a; a = aggregations.next())
         {
-            QString nm(cleanName(a-&gt;getObject(Uml::A)-&gt;getName()));
-            if (a-&gt;getMulti(Uml::A).isEmpty())
+            UMLObject *b = a-&gt;getObject(Uml::B);
+            if (b == c)
+                continue;   // we need to be at the &quot;A&quot; side and the other guy at &quot;B&quot;
+            QString nm(cleanName(b-&gt;getName()));
+            if (a-&gt;getMulti(Uml::B).isEmpty())
                 js &lt;&lt; m_indentation &lt;&lt; &quot;this.m_&quot; &lt;&lt; nm &lt;&lt; &quot; = new &quot; &lt;&lt; nm &lt;&lt; &quot; ();&quot; &lt;&lt; m_endl;
             else
                 js &lt;&lt; m_indentation &lt;&lt; &quot;this.m_&quot; &lt;&lt; nm.lower() &lt;&lt; &quot; = new Array ();&quot; &lt;&lt; m_endl;
@@ -168,8 +171,11 @@
         js &lt;&lt; m_endl &lt;&lt; m_indentation &lt;&lt; &quot;/**Compositions: */&quot; &lt;&lt; m_endl;
         for (UMLAssociation *a = compositions.first(); a; a = compositions.next())
         {
-            QString nm(cleanName(a-&gt;getObject(Uml::A)-&gt;getName()));
-            if(a-&gt;getMulti(Uml::A).isEmpty())
+            UMLObject *b = a-&gt;getObject(Uml::B);
+            if (b == c)
+                continue;   // we need to be at the &quot;A&quot; side and the other guy at &quot;B&quot;
+            QString nm(cleanName(b-&gt;getName()));
+            if (a-&gt;getMulti(Uml::B).isEmpty())
                 js &lt;&lt; m_indentation &lt;&lt; &quot;this.m_&quot; &lt;&lt; nm &lt;&lt; &quot; = new &quot;&lt;&lt; nm &lt;&lt; &quot; ();&quot; &lt;&lt; m_endl;
             else
                 js &lt;&lt; m_indentation &lt;&lt; &quot;this.m_&quot; &lt;&lt; nm.lower() &lt;&lt; &quot; = new Array ();&quot; &lt;&lt; m_endl;
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>