Bug 345571 - Crash when copying actor of use case to collaboration diagram
Summary: Crash when copying actor of use case to collaboration diagram
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.15.3 (KDE Applications 14.12.3)
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-27 12:12 UTC by robin007bond
Modified: 2015-05-08 08:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description robin007bond 2015-03-27 12:12:33 UTC
Application: umbrello (2.15.3)
KDE Platform Version: 4.14.6
Qt Version: 4.8.6
Operating System: Linux 3.19.2-1-ARCH x86_64
Distribution: "Arch Linux"

-- Information about the crash:
The program crashes when an "actor" from a use case diagram is copied to a collaboration diagram.

The crash can be reproduced every time.

-- Backtrace:
A useful backtrace could not be generated, according to the KDE Bug Reporting program. 

Reproducible: Always

Steps to Reproduce:
1) Created a new collaboration diagram
2) Created a new use case diagram
3) Made a new actor with a random name
4) Copied the actor and pasted it in the collaboration diagram 
5) I got the message: "Umbrello could not paste the clipboard contents.  The objects in the clipboard may be of the wrong type to be pasted here."
6) Umbrello quits and the KDE Bug Report window pops up.

Actual Results:  
Umbrello crashes

Expected Results:  
The actor correctly copied in the collaboration diagram
Comment 1 Ralf Habacker 2015-05-06 06:01:32 UTC
After 5) I need to click into the diagram to trigger the crash.
Comment 2 Ralf Habacker 2015-05-06 06:09:27 UTC
Pasting code is performed by the following methods: 
0	UMLClipboard::checkPasteWidgets	umlclipboard.cpp	771	0x49ed60	
1	UMLClipboard::pasteClip4	umlclipboard.cpp	529	0x4a0074	
2	UMLClipboard::paste	umlclipboard.cpp	211	0x4a101b	
3	UMLApp::slotEditPaste	uml.cpp	1566	0x63e851	

The problem here is, that UMLClipboard::checkPasteWidgets() deletes the widget, while UMLDragData::decodeClip4(), which is called from pasteClip4(), already added the widget to the scene widget list. Accessing afterwards the scene's widget list returns a dangled widget pointer and result into the crash.
Comment 3 Ralf Habacker 2015-05-07 09:58:39 UTC
A workaround is to drag and drop the actor from the tree view into the collaboration diagram.
Comment 4 Ralf Habacker 2015-05-08 08:01:06 UTC
Git commit 66ed34766b015c56a4f1ed880d614a9127c44697 by Ralf Habacker.
Committed on 08/05/2015 at 07:50.
Pushed by habacker into branch 'Applications/15.04'.

Refactor code checking valid uml object type for a given diagram type into a new function Moodel_Utils::typeIsAllowedInDiagram().

This makes the function callable from different locations.

M  +79   -0    umbrello/model_utils.cpp
M  +1    -0    umbrello/model_utils.h
M  +1    -65   umbrello/umlscene.cpp

http://commits.kde.org/umbrello/66ed34766b015c56a4f1ed880d614a9127c44697
Comment 5 Ralf Habacker 2015-05-08 08:01:06 UTC
Git commit 5a05d35e2e809899b2f65bea9fb44681042d10f8 by Ralf Habacker.
Committed on 08/05/2015 at 07:58.
Pushed by habacker into branch 'Applications/15.04'.

Fix 'Crash when copying actor of use case to collaboration diagram'.

The crash happened by accessing deleted widgets in the scene widget list; the bug
is fixed by excluding invalid uml objects and widget in UMLDragData::decodeClip4()
before any widget is added to the scene.

M  +0    -47   umbrello/clipboard/umlclipboard.cpp
M  +0    -2    umbrello/clipboard/umlclipboard.h
M  +22   -0    umbrello/clipboard/umldragdata.cpp
M  +46   -0    umbrello/model_utils.cpp
M  +1    -0    umbrello/model_utils.h

http://commits.kde.org/umbrello/5a05d35e2e809899b2f65bea9fb44681042d10f8