Gui: avoid unecessary visibility change when update view provider
This patch prevents syncing DocumentObject::Visibility when view provider hides itself before updating. Some object may have additional logic based on object visibility change. For example, GroupExtension monitors its children visibility for exporting, and propgate changes to upper hierarchy.
This commit is contained in:
@@ -183,8 +183,12 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop)
|
||||
Visibility.getValue() ? show() : hide();
|
||||
Visibility.setStatus(App::Property::User2, false);
|
||||
}
|
||||
if(getObject() && getObject()->Visibility.getValue()!=Visibility.getValue())
|
||||
if (!Visibility.testStatus(App::Property::User1)
|
||||
&& getObject()
|
||||
&& getObject()->Visibility.getValue()!=Visibility.getValue())
|
||||
{
|
||||
getObject()->Visibility.setValue(Visibility.getValue());
|
||||
}
|
||||
}
|
||||
else if (prop == &SelectionStyle) {
|
||||
if(getRoot()->isOfType(SoFCSelectionRoot::getClassTypeId())) {
|
||||
@@ -239,6 +243,9 @@ void ViewProviderDocumentObject::updateView()
|
||||
|
||||
Base::ObjectStatusLocker<ViewStatus,ViewProviderDocumentObject> lock(ViewStatus::UpdatingView,this);
|
||||
|
||||
// Disable object visibility syncing
|
||||
Base::ObjectStatusLocker<App::Property::Status,App::Property> lock2(App::Property::User1, &Visibility);
|
||||
|
||||
std::map<std::string, App::Property*> Map;
|
||||
pcObject->getPropertyMap(Map);
|
||||
|
||||
@@ -298,8 +305,12 @@ void ViewProviderDocumentObject::update(const App::Property* prop)
|
||||
if(prop == &getObject()->Visibility) {
|
||||
if(!isRestoring() && Visibility.getValue()!=getObject()->Visibility.getValue())
|
||||
Visibility.setValue(!Visibility.getValue());
|
||||
}else
|
||||
} else {
|
||||
// Disable object visibility syncing
|
||||
Base::ObjectStatusLocker<App::Property::Status,App::Property>
|
||||
guard(App::Property::User1, &Visibility);
|
||||
ViewProvider::update(prop);
|
||||
}
|
||||
}
|
||||
|
||||
Gui::Document* ViewProviderDocumentObject::getDocument() const
|
||||
|
||||
Reference in New Issue
Block a user