ObjectIdentifier: Reworked resolve() function to solve issue #2389 and #2418.

* Refactored code; moved mutable fields into a separate inner class.
* Added resolvedProperty to ResolveResults class.
* Set resolved document name, even if it does not resolve correctly, so we can give a better error message later.
* If the document name is explicitly set, and it does not resolve, don't try any further.
* If document name is set, use that instead of the ObjectIdentifier's owner when looking up the document object.
This commit is contained in:
Eivind Kvedalen
2016-01-26 22:22:45 +01:00
committed by wmayer
parent 183f8dfebe
commit e5f1e298a6
2 changed files with 173 additions and 106 deletions

View File

@@ -227,23 +227,32 @@ public:
protected:
struct ResolveResults {
ResolveResults(const ObjectIdentifier & oi);
int propertyIndex;
App::Document * resolvedDocument;
String resolvedDocumentName;
App::DocumentObject * resolvedDocumentObject;
String resolvedDocumentObjectName;
App::Property * resolvedProperty;
std::string propertyName;
};
std::string getPythonAccessor() const;
void resolve() const;
void resolve(ResolveResults & results) const;
App::DocumentObject *getDocumentObject(const App::Document *doc, const String &name, bool &byIdentifier) const;
const App::PropertyContainer * owner;
String documentName;
bool documentNameSet;
String documentObjectName;
bool documentObjectNameSet;
std::vector<Component> components;
/// Mutable elements, updated by resolve()
mutable int propertyIndex;
mutable String documentName;
mutable String documentObjectName;
mutable std::string propertyName;
};
std::size_t hash_value(const App::ObjectIdentifier & path);