Thanks for a quick answer. This line was obviously incorrect, but it does not solve all the issues.

If you try a random combination of double clicking or holding mouse button on the item that is going to be removed there is still an issue with parent() function.

The backtrace from GDB gives something like:

Qt Code:
  1. (gdb) back
  2. #0 0x0804e73d in AbstractModel::parent(QModelIndex const&) const ()
  3. #1 0x008478a6 in QTreeView::drawRow(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const () from /usr/lib/libQtGui.so.4
  4. #2 0x008514a9 in QTreeView::drawTree(QPainter*, QRegion const&) const () from /usr/lib/libQtGui.so.4
  5. #3 0x008545bd in QTreeView::paintEvent(QPaintEvent*) () from /usr/lib/libQtGui.so.4
  6. #4 0x002c16b6 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
  7. #5 0x006bdfd3 in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
  8. #6 0x00758382 in QAbstractScrollArea::viewportEvent(QEvent*) () from /usr/lib/libQtGui.so.4
  9. #7 0x0080cbd7 in QAbstractItemView::viewportEvent(QEvent*) () from /usr/lib/libQtGui.so.4
  10. #8 0x0084df7c in QTreeView::viewportEvent(QEvent*) () from /usr/lib/libQtGui.so.4
  11. #9 0x0075ac65 in ?? () from /usr/lib/libQtGui.so.4
  12. #10 0x00d11cda in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
  13. #11 0x002634b9 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
  14. #12 0x0026a0f9 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
  15. #13 0x00d12a3b in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
  16. #14 0x002ca9d6 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) () from /usr/lib/libQtGui.so.4
  17. #15 0x004a17d7 in ?? () from /usr/lib/libQtGui.so.4
  18. #16 0x002bab93 in QWidgetPrivate::syncBackingStore() () from /usr/lib/libQtGui.so.4
  19. #17 0x002c1e76 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
  20. #18 0x006bdfd3 in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
  21. #19 0x00758d97 in QAbstractScrollArea::event(QEvent*) () from /usr/lib/libQtGui.so.4
  22. #20 0x0080582c in QAbstractItemView::event(QEvent*) () from /usr/lib/libQtGui.so.4
  23. #21 0x002634dc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
  24. #22 0x0026a0f9 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
  25. #23 0x00d12a3b in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
  26. #24 0x00d15473 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQtCore.so.4
  27. #25 0x00d155dd in QCoreApplication::sendPostedEvents(QObject*, int) () from /usr/lib/libQtCore.so.4
To copy to clipboard, switch view to plain text mode 

I should mention that this of course is a simple code for bug catching taken from a bigger application with enhanced functionality.