diff --git a/src/Gui/PropertyView.cpp b/src/Gui/PropertyView.cpp index 5cf59968a4..01c4291fb6 100644 --- a/src/Gui/PropertyView.cpp +++ b/src/Gui/PropertyView.cpp @@ -136,6 +136,12 @@ PropertyView::PropertyView(QWidget *parent) this->connectDelDocument = Application::Instance->signalDeleteDocument.connect( boost::bind(&PropertyView::slotDeleteDocument, this, _1)); + this->connectDelViewObject = + Application::Instance->signalDeletedObject.connect( + boost::bind(&PropertyView::slotDeletedViewObject, this, _1)); + this->connectDelObject = + App::GetApplication().signalDeletedObject.connect( + boost::bind(&PropertyView::slotDeletedObject, this, _1)); } PropertyView::~PropertyView() @@ -149,6 +155,8 @@ PropertyView::~PropertyView() this->connectRedoDocument.disconnect(); this->connectActiveDoc.disconnect(); this->connectDelDocument.disconnect(); + this->connectDelObject.disconnect(); + this->connectDelViewObject.disconnect(); } static bool _ShowAll; @@ -253,6 +261,25 @@ void PropertyView::slotDeleteDocument(const Gui::Document &doc) { propertyEditorView->buildUp(); propertyEditorData->buildUp(); clearPropertyItemSelection(); + timer->start(50); + } +} + +void PropertyView::slotDeletedViewObject(const Gui::ViewProvider &vp) { + if(propertyEditorView->propOwners.count(&vp)) { + propertyEditorView->buildUp(); + propertyEditorData->buildUp(); + clearPropertyItemSelection(); + timer->start(50); + } +} + +void PropertyView::slotDeletedObject(const App::DocumentObject &obj) { + if(propertyEditorData->propOwners.count(&obj)) { + propertyEditorView->buildUp(); + propertyEditorData->buildUp(); + clearPropertyItemSelection(); + timer->start(50); } } @@ -297,10 +324,7 @@ void PropertyView::onSelectionChanged(const SelectionChanges& msg) return; // clear the properties. - propertyEditorData->buildUp(); - propertyEditorView->buildUp(); - clearPropertyItemSelection(); - timer->start(100); + timer->start(50); } void PropertyView::onTimer() { @@ -310,6 +334,9 @@ void PropertyView::onTimer() { clearPropertyItemSelection(); timer->stop(); + if(!this->isConnectionAttached()) + return; + if(!Gui::Selection().hasSelection()) { auto gdoc = TreeWidget::selectedDocument(); if(!gdoc || !gdoc->getDocument()) @@ -477,7 +504,7 @@ void PropertyView::onTimer() { for(auto &v : dataPropsMap) dataProps.emplace_back(v.first,std::move(v.second)); - propertyEditorData->buildUp(std::move(dataProps)); + propertyEditorData->buildUp(std::move(dataProps),true); for (it = propViewMap.begin(); it != propViewMap.end(); ++it) { if (it->propList.size() == sels.size()) diff --git a/src/Gui/PropertyView.h b/src/Gui/PropertyView.h index b88ca17c29..bac0dde71c 100644 --- a/src/Gui/PropertyView.h +++ b/src/Gui/PropertyView.h @@ -89,6 +89,8 @@ private: void slotRollback(); void slotActiveDocument(const Gui::Document&); void slotDeleteDocument(const Gui::Document&); + void slotDeletedViewObject(const Gui::ViewProvider&); + void slotDeletedObject(const App::DocumentObject&); void checkEnable(const char *doc = 0); @@ -105,6 +107,8 @@ private: Connection connectRedoDocument; Connection connectActiveDoc; Connection connectDelDocument; + Connection connectDelObject; + Connection connectDelViewObject; QTabWidget* tabs; QTimer* timer; }; diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 264c553e11..274e178bb0 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -306,7 +306,7 @@ void PropertyEditor::drawBranches(QPainter *painter, const QRect &rect, const QM //painter->setPen(savedPen); } -void PropertyEditor::buildUp(PropertyModel::PropertyList &&props) +void PropertyEditor::buildUp(PropertyModel::PropertyList &&props, bool checkDocument) { if (committing) { Base::Console().Warning("While committing the data to the property the selection has changed.\n"); @@ -327,8 +327,15 @@ void PropertyEditor::buildUp(PropertyModel::PropertyList &&props) propList = std::move(props); propOwners.clear(); for(auto &v : propList) { - for(auto prop : v.second) - propOwners.insert(prop->getContainer()); + for(auto prop : v.second) { + auto container = prop->getContainer(); + if(!container) + continue; + // Include document to get proper handling in PropertyView::slotDeleteDocument() + if(checkDocument && container->isDerivedFrom(App::DocumentObject::getClassTypeId())) + propOwners.insert(static_cast(container)->getDocument()); + propOwners.insert(container); + } } } diff --git a/src/Gui/propertyeditor/PropertyEditor.h b/src/Gui/propertyeditor/PropertyEditor.h index a64371d407..775a04b625 100644 --- a/src/Gui/propertyeditor/PropertyEditor.h +++ b/src/Gui/propertyeditor/PropertyEditor.h @@ -72,7 +72,7 @@ public: ~PropertyEditor(); /** Builds up the list view with the properties. */ - void buildUp(PropertyModel::PropertyList &&props = PropertyModel::PropertyList()); + void buildUp(PropertyModel::PropertyList &&props = PropertyModel::PropertyList(), bool checkDocument=false); void updateProperty(const App::Property&); void updateEditorMode(const App::Property&); bool appendProperty(const App::Property&); @@ -113,7 +113,7 @@ private: PropertyModel* propertyModel; QStringList selectedProperty; PropertyModel::PropertyList propList; - std::unordered_set propOwners; + std::unordered_set propOwners; bool autoupdate; bool committing; bool delaybuild;