From 1b183a16b87d2dbfd413ce01a4ce40bbaf957ea5 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 16 Mar 2017 12:27:16 +0800 Subject: [PATCH] Gui.TreeWidget: check cyclic dep when populating --- src/Gui/Tree.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 73799cd14d..6db5ef7c06 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1109,7 +1109,7 @@ void DocumentItem::populateItem(DocumentObjectItem *item, bool refresh) { const char* name = child->getNameInDocument(); if (!name) { - Base::Console().Warning("Gui::DocumentItem::populate(): Cannot reparent unknown object.\n"); + Base::Console().Warning("Gui::DocumentItem::populateItem(): Cannot reparent unknown object.\n"); continue; } @@ -1127,6 +1127,12 @@ void DocumentItem::populateItem(DocumentObjectItem *item, bool refresh) { if(childItem->parent() != this) slotNewObject(item,*childItem->object()); else { + if(item->isChildOfItem(childItem)) { + Base::Console().Error("Gui::DocumentItem::populateItem(): Cyclic dependency in %s and %s\n", + item->object()->getObject()->Label.getValue(), + childItem->object()->getObject()->Label.getValue()); + continue; + } this->removeChild(childItem); item->addChild(childItem); } @@ -1575,7 +1581,5 @@ void DocumentObjectItem::slotChangeStatusTip(const QString& tip) this->setStatusTip(0, tip); } - - #include "moc_Tree.cpp"