App: fix Link extensionGetPropertyByName()

Do not query linked object if the owner object has property with the
given name.
This commit is contained in:
Zheng, Lei
2020-08-19 11:32:49 +08:00
committed by wmayer
parent 3423e72679
commit c5ce992786
2 changed files with 17 additions and 7 deletions

View File

@@ -34,6 +34,7 @@
#include "Link.h"
#include "LinkBaseExtensionPy.h"
#include <Base/Console.h>
#include <Base/Tools.h>
#include "ComplexGeoData.h"
#include "ComplexGeoDataPy.h"
@@ -1421,14 +1422,21 @@ static bool isExcludedProperties(const char *name) {
}
Property *LinkBaseExtension::extensionGetPropertyByName(const char* name) const {
auto prop = inherited::extensionGetPropertyByName(name);
if(prop || isExcludedProperties(name))
return prop;
if (checkingProperty)
return inherited::extensionGetPropertyByName(name);
Base::StateLocker guard(checkingProperty);
if(isExcludedProperties(name))
return nullptr;
auto owner = getContainer();
if(owner && owner->canLinkProperties()) {
auto linked = getTrueLinkedObject(true);
if(linked)
return linked->getPropertyByName(name);
if (owner) {
App::Property *prop = owner->getPropertyByName(name);
if(prop)
return prop;
if(owner->canLinkProperties()) {
auto linked = getTrueLinkedObject(true);
if(linked)
return linked->getPropertyByName(name);
}
}
return 0;
}

View File

@@ -319,6 +319,8 @@ protected:
mutable bool enableLabelCache;
bool hasOldSubElement;
mutable bool checkingProperty = false;
};
///////////////////////////////////////////////////////////////////////////