Bug 449297 - Code import wizard: python wrong function return
Summary: Code import wizard: python wrong function return
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: importer (show other bugs)
Version: 2.32.0 (KDE releases 20.08.0)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-28 16:47 UTC by Jessica
Modified: 2022-01-31 20:57 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 2.33.80 (KDE releases 22.03.80)


Attachments
Python source + umbrello file for this source (5.08 KB, application/x-zip-compressed)
2022-01-28 16:47 UTC, Jessica
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jessica 2022-01-28 16:47:02 UTC
Created attachment 146016 [details]
Python source + umbrello file for this source

STEPS TO REPRODUCE
1.  Import the file pong.py
2. Drag-and-drop classes ball and paddle to a class diagram
3. Compare pong.py to the class diagram and see that the class functions do not return a String, while in the class diagram they return a String.

OBSERVED RESULT
the class functions do not return a String but in the class diagram they return a String.

EXPECTED RESULT
The class diagram should not have an unexisting return type String for class functions.


SOFTWARE/OS VERSIONS

Windows: Microsoft Windows [Version 10.0.19044.1466]

KDE Development Platform 4.14.65

ADDITIONAL INFORMATION
Included in the zip file: pong.py and pong.xmi
Comment 1 Oliver Kellogg 2022-01-31 20:57:14 UTC
Git commit 126264fdacc53e6d209258115a5d977a1ac3c82e by Oliver Kellogg.
Committed on 31/01/2022 at 20:57.
Pushed by okellogg into branch 'master'.

Fix "Code import wizard: python wrong function return"

umbrello/codeimport/pythonimport.{h,cpp}
- At function skipBody add optional argument foundReturn of type bool*.
  If given then the variable pointed to will be set true if a 'return'
  statement was encountered while skipping.
  If no 'return' statement was encountered then the variable will be set
  to false.
- In function parseStmt() handling of keyword "def" :
  - Move local srcIndex and call to op->setSourceCode to before the call
    to Import_Utils::insertMethod.
  - Define local foundReturn of type bool.
  - Define local QString bodyCode initialized to skipBody(&foundReturn).
  - Define local QString returnTypeName which is left empty if
    foundReturn is returned false and is set to "string" if foundReturn
    is returned true.
  - At call to Import_Utils::insertMethod provide returnTypeName as the
    return type argument.
  - At call to op->setSourceCode provide bodyCode as argument.
FIXED-IN:2.33.80 (KDE releases 22.03.80)

M  +18   -4    umbrello/codeimport/pythonimport.cpp
M  +1    -1    umbrello/codeimport/pythonimport.h

https://invent.kde.org/sdk/umbrello/commit/126264fdacc53e6d209258115a5d977a1ac3c82e