Summary: | Javascript wrong Code Generation | ||
---|---|---|---|
Product: | [Applications] umbrello | Reporter: | ediaz666 <ediaz666> |
Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
ediaz666@gmail.com
2006-10-12 19:52:55 UTC
I can'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 | <>-----| 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'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'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't be a composant m_A in class A. In my example, there is only one composant m_A in class A. That's better than many but still incorrect PS : The generated code is identical in trunk 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 << m_endl << m_indentation << "/**Aggregations: */" << m_endl; for (UMLAssociation* a = aggregations.first(); a; a = aggregations.next()) { - QString nm(cleanName(a->getObject(Uml::A)->getName())); - if (a->getMulti(Uml::A).isEmpty()) + UMLObject *b = a->getObject(Uml::B); + if (b == c) + continue; // we need to be at the "A" side and the other guy at "B" + QString nm(cleanName(b->getName())); + if (a->getMulti(Uml::B).isEmpty()) js << m_indentation << "this.m_" << nm << " = new " << nm << " ();" << m_endl; else js << m_indentation << "this.m_" << nm.lower() << " = new Array ();" << m_endl; @@ -168,8 +171,11 @@ js << m_endl << m_indentation << "/**Compositions: */" << m_endl; for (UMLAssociation *a = compositions.first(); a; a = compositions.next()) { - QString nm(cleanName(a->getObject(Uml::A)->getName())); - if(a->getMulti(Uml::A).isEmpty()) + UMLObject *b = a->getObject(Uml::B); + if (b == c) + continue; // we need to be at the "A" side and the other guy at "B" + QString nm(cleanName(b->getName())); + if (a->getMulti(Uml::B).isEmpty()) js << m_indentation << "this.m_" << nm << " = new "<< nm << " ();" << m_endl; else js << m_indentation << "this.m_" << nm.lower() << " = new Array ();" << m_endl; |