Bug 377613

Summary: c++ codegenerator creates uncompilable code using compositions
Product: [Applications] umbrello Reporter: Ralf Habacker <ralf.habacker>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: CONFIRMED ---    
Severity: normal CC: nitinjavakid
Priority: NOR    
Version: 2.21.2 (KDE Applications 16.12.2)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: xmi test case
Simplified Test Case

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.