Skip to content
Commit 7e382cda authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

Apply "Fix: crashing when {un,re}do commands"

https://mail.kde.org/pipermail/umbrello-devel/2022-April/023234.html



Executing {un,re}do commands a sigsegv happens as follows:

> [...]
> at
> /umbrello_git/umbrello/cmds/widget/cmdbasewidgetcommand.cpp:77
> (this=0x7fffe4006f10)
> at
> /umbrello_git/umbrello/cmds/widget/cmdcreatewidget.cpp:124

When `undo' command is triggered, it calls to `o->deleteLater' getting
out of memory the `widget' object, then, doing a `redo' command this
object is not longer available, so an invalid `m_widget' reference is
used.  This patch change this behavior calling `{add,remove}Item' member
function from `{re,un}do' callbacks respectively triggered by
`QUndoStack::push' member.

umbrello/cmds/widget/cmdcreatewidget.cpp
- Move call to addWidgetToScene from constructor to function redo().
- In function redo() use `addWidgetToScene' with `m_widget', updating
  scene object.

umbrello/umlscene.cpp
- In function removeWidgetCmd() remove `o->deleteLater' updating the
  scene.

Signed-off-by: default avatarGuillermo E. Martinez <guillermo.e.martinez@oracle.com>
parent 257f0919
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment