[Uml-devel] Segfault on document close

Achim Spangler Achim.Spangler at mnet-online.de
Thu Nov 30 19:36:33 UTC 2006


Hi,

I have currently very often a segfault on document close.

The relevant part of stack trace:
[KCrash handler]
#6  0x00000049 in ?? ()
#7  0xb7137932 in QGList::clear () from /usr/lib/libqt-mt.so.3
#8  0x0816a336 in QPtrList<QCanvasLine>::~QPtrList ()
#9  0x08190ab5 in ToolBarStateArrow::~ToolBarStateArrow ()
#10 0xb6e701c3 in QWidget::~QWidget () from /usr/lib/libqt-mt.so.3
#11 0xb6f70acc in QScrollView::~QScrollView () from /usr/lib/libqt-mt.so.3
#12 0xb706c7b8 in QCanvasView::~QCanvasView () from /usr/lib/libqt-mt.so.3
#13 0x081c0d44 in UMLView::~UMLView ()


I have the impression, that ToolBarStateArrow::~ToolBarStateArrow() does 
implicitly call QPtrList<QCanvasLine>::~QPtrList ( QPtrList<QCanvasLine> 
m_selectionRect). The m_selectionRect has been set with

m_selectionRect.setAutoDelete(true);

to automatically delete the pointed QCanvasLine objects.

The problem:
The UMLView::~UMLView() ((#13)) calls "delete canvas();" before, so that _all_ 
items which belong to the canvas are deleted immediately:


From Qt-Doc:
QCanvas::~QCanvas () [virtual] 
 Destroys the canvas and all the canvas's canvas items. 


The QCanvasLine are obiously also part of the containing QCanvas, so that its 
destructor deletes them already. Therefore the later destructor of 
QPtrList<QCanvasLine> goes "mad".

My suggestion:
Call "m_selectionRect.setAutoDelete(false);" in 
ToolBarStateArrow::~ToolBarStateArrow().
OR
Explicitly destroy ToolBarStateArrow _before_ "delete canvas" is called.
Therefore call
"delete m_pToolBarStateFactory"
in UMLView::~UMLView() _BEFORE_ "delete canvas" is called.

I'll try the latter approach for myself.

Does anyone have a better idea?

Thanks,
Achim




More information about the umbrello-devel mailing list