vfernandez
30th December 2006, 17:00
I have a backend thread that parses the Apache configuration files and builds a tree (ConfigTree is the base class). Now I'm writing a dialog with a model and a view to let the user view the tree. It may be opened through the menu in the main window but the application crashes just on opening it. This is the backtrace:
#0 0x0805a644 in q_atomic_increment (ptr=0x20) at /usr/lib/qt4/include/QtCore/qatomic_i386.h:70
#1 0x0805a6ab in QBasicAtomic::ref (this=0x20) at /usr/lib/qt4/include/QtCore/qatomic.h:71
#2 0x080653e5 in QList (this=0xbfc12a60, l=@0x8287098) at /usr/lib/qt4/include/QtCore/qlist.h:90
#3 0x08066b88 in ConfigTree::children (this=0x8287080) at configtree.cpp:66
#4 0x081010a5 in ParsedTreeModel::rowCount (this=0x83bdee8, parent=@0x84853f8) at parsedtreemodel.cpp:183
#5 0xb7453bc5 in QAbstractItemModel::hasChildren (this=0x83bdee8, parent=@0x84853f8) at kernel/qabstractitemmodel.cpp:1286
#6 0xb7cb3b2b in QTreeViewPrivate::hasVisibleChildren (this=0x8473660, parent=@0x84853f8) at itemviews/qtreeview.cpp:2830
#7 0xb7cb3f35 in QTreeView::drawBranches (this=0x83ed4c0, painter=0xbfc12f90, rect=@0xbfc12cf8, index=@0x84853f8)
at itemviews/qtreeview.cpp:1270
#8 0xb7cb121c in QTreeView::drawRow (this=0x83ed4c0, painter=0xbfc12f90, option=@0xbfc12e7c, index=@0x84853f8)
at itemviews/qtreeview.cpp:1207
#9 0xb7cb1955 in QTreeView::drawTree (this=0x83ed4c0, painter=0xbfc12f90, region=@0xbfc13730) at itemviews/qtreeview.cpp:1046
#10 0xb7cb29f3 in QTreeView::paintEvent (this=0x83ed4c0, event=0xbfc13714) at itemviews/qtreeview.cpp:988
#11 0xb78830cd in QWidget::event (this=0x83ed4c0, event=0xbfc13714) at kernel/qwidget.cpp:5707
#12 0xb7b8e54c in QFrame::event (this=0x83ed4c0, e=0xbfc13714) at widgets/qframe.cpp:633
#13 0xb7c0abe5 in QAbstractScrollArea::viewportEvent (this=0x83ed4c0, e=0xbfc13714) at widgets/qabstractscrollarea.cpp:841
#14 0xb7c7a81b in QAbstractItemView::viewportEvent (this=0x83ed4c0, event=0xbfc13714) at itemviews/qabstractitemview.cpp:1273
#15 0xb7c0daa6 in QAbstractScrollAreaPrivate::viewportEvent (this=0x8473660, event=0xbfc13714) at widgets/qabstractscrollarea_p.h:78
#16 0xb7c0dad8 in QAbstractScrollAreaFilter::eventFilter (this=0x83bde20, o=0x83dc048, e=0xbfc13714) at widgets/qabstractscrollarea_p.h:89
#17 0xb783058e in QApplicationPrivate::notify_helper (this=0x818d208, receiver=0x83dc048, e=0xbfc13714) at kernel/qapplication.cpp:3427
#18 0xb783232a in QApplication::notify (this=0xbfc14954, receiver=0x83dc048, e=0xbfc13714) at kernel/qapplication.cpp:3376
#19 0xb783acb5 in QCoreApplication::sendSpontaneousEvent (receiver=0x83dc048, event=0xbfc13714)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:186
It's crashing in ConfigTree::children() which simply returns the children of a given node:
QList<ConfigNode*> ConfigTree::children()
{
return m_children;
}
It's called by the model in rowCount(). The line 183 is the return.
int ParsedTreeModel::rowCount(const QModelIndex &parent) const
{
if(!m_parser)
return 0;
ConfigTree *parentTree;
QMutexLocker locker(m_parser->parsedTreeMutex());
if (!parent.isValid())
parentTree = m_parser->parsedTree();
else {
parentTree = static_cast<ConfigTree*>(parent.internalPointer());
if(!parentTree)
return 0;
}
return parentTree->children().size();
}
The parent ConfigTree belongs to the Parser, which runs in the backend thread. So the source of the problem may come that way but I've no idea why it crashes. Any idea?
#0 0x0805a644 in q_atomic_increment (ptr=0x20) at /usr/lib/qt4/include/QtCore/qatomic_i386.h:70
#1 0x0805a6ab in QBasicAtomic::ref (this=0x20) at /usr/lib/qt4/include/QtCore/qatomic.h:71
#2 0x080653e5 in QList (this=0xbfc12a60, l=@0x8287098) at /usr/lib/qt4/include/QtCore/qlist.h:90
#3 0x08066b88 in ConfigTree::children (this=0x8287080) at configtree.cpp:66
#4 0x081010a5 in ParsedTreeModel::rowCount (this=0x83bdee8, parent=@0x84853f8) at parsedtreemodel.cpp:183
#5 0xb7453bc5 in QAbstractItemModel::hasChildren (this=0x83bdee8, parent=@0x84853f8) at kernel/qabstractitemmodel.cpp:1286
#6 0xb7cb3b2b in QTreeViewPrivate::hasVisibleChildren (this=0x8473660, parent=@0x84853f8) at itemviews/qtreeview.cpp:2830
#7 0xb7cb3f35 in QTreeView::drawBranches (this=0x83ed4c0, painter=0xbfc12f90, rect=@0xbfc12cf8, index=@0x84853f8)
at itemviews/qtreeview.cpp:1270
#8 0xb7cb121c in QTreeView::drawRow (this=0x83ed4c0, painter=0xbfc12f90, option=@0xbfc12e7c, index=@0x84853f8)
at itemviews/qtreeview.cpp:1207
#9 0xb7cb1955 in QTreeView::drawTree (this=0x83ed4c0, painter=0xbfc12f90, region=@0xbfc13730) at itemviews/qtreeview.cpp:1046
#10 0xb7cb29f3 in QTreeView::paintEvent (this=0x83ed4c0, event=0xbfc13714) at itemviews/qtreeview.cpp:988
#11 0xb78830cd in QWidget::event (this=0x83ed4c0, event=0xbfc13714) at kernel/qwidget.cpp:5707
#12 0xb7b8e54c in QFrame::event (this=0x83ed4c0, e=0xbfc13714) at widgets/qframe.cpp:633
#13 0xb7c0abe5 in QAbstractScrollArea::viewportEvent (this=0x83ed4c0, e=0xbfc13714) at widgets/qabstractscrollarea.cpp:841
#14 0xb7c7a81b in QAbstractItemView::viewportEvent (this=0x83ed4c0, event=0xbfc13714) at itemviews/qabstractitemview.cpp:1273
#15 0xb7c0daa6 in QAbstractScrollAreaPrivate::viewportEvent (this=0x8473660, event=0xbfc13714) at widgets/qabstractscrollarea_p.h:78
#16 0xb7c0dad8 in QAbstractScrollAreaFilter::eventFilter (this=0x83bde20, o=0x83dc048, e=0xbfc13714) at widgets/qabstractscrollarea_p.h:89
#17 0xb783058e in QApplicationPrivate::notify_helper (this=0x818d208, receiver=0x83dc048, e=0xbfc13714) at kernel/qapplication.cpp:3427
#18 0xb783232a in QApplication::notify (this=0xbfc14954, receiver=0x83dc048, e=0xbfc13714) at kernel/qapplication.cpp:3376
#19 0xb783acb5 in QCoreApplication::sendSpontaneousEvent (receiver=0x83dc048, event=0xbfc13714)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:186
It's crashing in ConfigTree::children() which simply returns the children of a given node:
QList<ConfigNode*> ConfigTree::children()
{
return m_children;
}
It's called by the model in rowCount(). The line 183 is the return.
int ParsedTreeModel::rowCount(const QModelIndex &parent) const
{
if(!m_parser)
return 0;
ConfigTree *parentTree;
QMutexLocker locker(m_parser->parsedTreeMutex());
if (!parent.isValid())
parentTree = m_parser->parsedTree();
else {
parentTree = static_cast<ConfigTree*>(parent.internalPointer());
if(!parentTree)
return 0;
}
return parentTree->children().size();
}
The parent ConfigTree belongs to the Parser, which runs in the backend thread. So the source of the problem may come that way but I've no idea why it crashes. Any idea?