Bug 373382 - Java import crashes on importing enums
Summary: Java import crashes on importing enums
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.20.3 (KDE Applications 16.08.3)
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-07 12:34 UTC by Ralf Habacker
Modified: 2017-01-09 00:47 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 2.21.2 [KDE Applications 16.12.1)
Sentry Crash Report:


Attachments
testclient.java (147 bytes, text/x-java)
2016-12-07 12:34 UTC, Ralf Habacker
Details
test.java (86 bytes, text/x-java)
2016-12-07 12:34 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2016-12-07 12:34:25 UTC
Created attachment 102659 [details]
testclient.java

Importing the appended java testcases (first testclient.java, then test.java) let umbrello crash.

Stack trace:
0	QList<QPointer<UMLObject>>::QList	qlist.h	122	0x4692f4	
1	QListIterator<QPointer<UMLObject>>::QListIterator	qlist.h	902	0x4d4439	
2	UMLCanvasObject::findChildObject	umlcanvasobject.cpp	244	0x5c2502	
3	UMLEnum::addEnumLiteral	enum.cpp	134	0x5b62c2	
4	Import_Utils::addEnumLiteral	import_utils.cpp	533	0x4f92f4	
5	JavaImport::parseStmt	javaimport.cpp	398	0x4fe938	
6	NativeImportBase::parseFile	nativeimportbase.cpp	490	0x50182a	
7	JavaImport::parseFile	javaimport.cpp	265	0x4ffe04	
8	ClassImport::importFiles	classimport.cpp	94	0x4f69f7	
9	UMLApp::importFiles	uml.cpp	2857	0x44f54e	
10	UMLApp::slotImportClass	uml.cpp	2884	0x44f719	
11	UMLListView::slotMenuSelection	umllistview.cpp	487	0x470dbd	
12	UMLListView::contextMenuEvent	umllistview.cpp	2076	0x471f85	
13	QWidget::event	qwidget.cpp	8567	0x7ffff29d9712	
14	QFrame::event	qframe.cpp	557	0x7ffff2d77b6e	
15	QAbstractItemView::viewportEvent	qabstractitemview.cpp	1644	0x7ffff2e87a93	
16	QTreeView::viewportEvent	qtreeview.cpp	1252	0x7ffff2ec69b0	
17	QCoreApplicationPrivate::sendThroughObjectEventFilters	qcoreapplication.cpp	1065	0x7ffff20f9fd6	
18	QApplicationPrivate::notify_helper	qapplication.cpp	4561	0x7ffff2986d7c	
19	QApplication::notify	qapplication.cpp	4187	0x7ffff298e0d8	
20	KApplication::notify		311	0x7ffff681483a	
...	<Mehr>				

Note: umbrello 2.15.3 did not crash but prints out the following warning: umbrello(25811) Model_Utils::findUMLObject: type mismatch for  "AnEnum"  (seeking type:  "ot_Enum" , found type:  "ot_Class" )
Comment 1 Ralf Habacker 2016-12-07 12:34:41 UTC
Created attachment 102660 [details]
test.java
Comment 2 Ralf Habacker 2016-12-07 12:43:55 UTC
The problem is that the importer creates UMLClassifier objects on any unknown parsed type e.g. at parsing  setEnum(Test.AnEnum.ValueA) it creates an UMLClassifier AnEnum in the package Test. On parsing the real definition (in test.java) later it tries to use the UMLClassifier as UMLEnum which fails.

In version 2.15.3 the type mismatch let umbrello completly ignore importing the enum which is not better.

Note: A similar issue related to importing an object which turns out later to be a package has been fixed with bug 336012.
Comment 3 Ralf Habacker 2017-01-09 00:45:19 UTC
Git commit 2af5a312245cda1d94c23a4a8ab0f2c9e413c143 by Ralf Habacker.
Committed on 09/01/2017 at 00:24.
Pushed by habacker into branch 'Applications/16.12'.

Fix 'Java import crashes on importing enums'.

This commit fixes the following issue: The importer creates UMLClassifier
objects on any unknown parsed type. On parsing the real definition later
it tries to use the UMLClassifier as UMLEnum which fails.

UMLDoc::setImporting() has been added to remove the old entry from the
tree view which is otherwise blocked in UMLListView::slotObjectRemoved()
by UmlDoc::loading().
FIXED-IN:2.21.1 [KDE Applications 16.12.1)

M  +2    -0    umbrello/codeimport/classimport.cpp
M  +17   -0    umbrello/codeimport/javaimport.cpp
M  +18   -0    umbrello/umldoc.cpp
M  +8    -0    umbrello/umldoc.h
M  +1    -1    umbrello/umllistview.cpp

https://commits.kde.org/umbrello/2af5a312245cda1d94c23a4a8ab0f2c9e413c143