Clearing a QTreeWidget in CustomContextMenuRequest causes crash
-
Hi,
I'm struggling to get the following work:
Ive connected a CustomContextMenuRequest to a QWidgetTree and indeed the menu pops open. But, however, when I want to clear this QWidgetTree in this request I get a null pointer exception. When i run this piece of code in another place or slot it works just fine.When there are multiple items present in the treewidget, i can delete them one for one, and everything works fine, but when I delete the last one the exception occurs again.
void N3LAB_Software::contextMenuTree(const QPoint& pos){ this->objectList->clear(); % The QTreeWidget }
Does somebody know whats causing this problem or how to fix this?
Thanks,
Perry
Ps:
Im using Qt 5.6 with visual studio 2015 -
Sure, here it is
Qt5Widgetsd.dll!QTreeWidgetItem::text(int column) Line 106 C++ N3LAB_Software.exe!N3LAB_Software::changedModelSelection(QTreeWidgetItem * currentItem, QTreeWidgetItem * oldItem) Line 276 C++ N3LAB_Software.exe!N3LAB_Software::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 108 C++ Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Line 3742 C++ Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3603 C++ Qt5Widgetsd.dll!QTreeWidget::currentItemChanged(QTreeWidgetItem * _t1, QTreeWidgetItem * _t2) Line 441 C++ Qt5Widgetsd.dll!QTreeWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex & current, const QModelIndex & previous) Line 2303 C++ Qt5Widgetsd.dll!QTreeWidget::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 212 C++ Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Line 3742 C++ Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3603 C++ Qt5Cored.dll!QItemSelectionModel::currentChanged(const QModelIndex & _t1, const QModelIndex & _t2) Line 488 C++ Qt5Cored.dll!QItemSelectionModel::clearCurrentIndex() Line 1320 C++ Qt5Cored.dll!QItemSelectionModel::clear() Line 1308 C++ Qt5Widgetsd.dll!QTreeWidget::clear() Line 3258 C++ N3LAB_Software.exe!N3LAB_Software::contextMenuTree(const QPoint & pos) Line 175 C++
-
@VRonin said in Clearing a QTreeWidget in CustomContextMenuRequest causes crash:
QTreeWidgetItem
Thank you very much, that I did not see this.
The changedModelSelection(QTreeWidgetItem* currentItem, QTreeWidgetItem* oldItem) which is called when a selection is changed in the tree wants to do an update, but as there are no objects left the currentItem is null and there for causes an exception when I want to do something with it.
4 days strugling for this, haha.