Bug 377613 - c++ codegenerator creates uncompilable code using compositions
Summary: c++ codegenerator creates uncompilable code using compositions
Status: CONFIRMED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.21.2 (KDE Applications 16.12.2)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-14 14:32 UTC by Ralf Habacker
Modified: 2017-04-03 22:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
xmi test case (12.54 KB, text/x-xmi)
2017-03-14 16:31 UTC, Ralf Habacker
Details
Simplified Test Case (12.08 KB, text/x-xmi)
2017-03-30 17:56 UTC, Nitin Anand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2017-03-14 14:32:21 UTC
Generating code from the appended xmi file is uncompilable because
1. the class member m_fileVector is of type 'std::vector<File*> while void addFile (File add_object) declaration uses full class
2. same as 1. with void removeFile (File remove_object);
3. The method definitions of 1. are of 'void Folder::addFile (File * add_object)' which differs from the declaration
4. same as 3 with 'void Folder::removeFile (File * remove_object)'
5. Folder::getFileList is defined as 'std::vector<File> getFileList ()' while it is defined as 'std::vector<File *> Folder::getFileList()'

How to reproduce:
1. start umbrello and load the appended xmi file
2. Generate c++ code
3. try to compile Folder.cpp

What happens:
The generated files are uncompilable

What is expected:
The generated files should be compilable
Comment 1 Ralf Habacker 2017-03-14 16:31:37 UTC
Created attachment 104565 [details]
xmi test case
Comment 2 Nitin Anand 2017-03-30 17:50:38 UTC
Yes associations are broken. Am currently investigating what broke it in code.
Comment 3 Nitin Anand 2017-03-30 17:56:54 UTC
Created attachment 104820 [details]
Simplified Test Case

Lesser classes
Comment 4 Ralf Habacker 2017-04-03 22:28:55 UTC
In CppWriter::writeHeaderAccessorMethodDecl() there is a call to     writeAssociationMethods(c->getCompositions(), permitScope,                          true, INLINE_ASSOCIATION_METHODS, false, c->id(), stream) which deals with compositions. 
This method generates the File composition in the class Folder *AND* the Folder pointer in the File class. For generating the composition the parameter writePointerVar is set to false to avoid generating classname followed by '*' in the accessor parameter list. Unfortunally writePointerVar = true is required to generate the classname followed by '*' in the accessor methods to m_folder in the File class. So with current code either class Folder is uncompilable or class File is uncompilable.