+ fix Enumeration::contains: the current index is irrelevant when searching for an entry in the enumeration

+ only print a warning if the enumeration is not empty but the restored index is < 0
This commit is contained in:
wmayer
2020-05-19 08:45:02 +02:00
parent a724961ca3
commit 8fcd436de1
2 changed files with 4 additions and 2 deletions

View File

@@ -220,7 +220,7 @@ bool Enumeration::contains(const char *value) const
// using string methods without set, use setEnums(const char** plEnums) first!
//assert(_EnumArray);
if (!isValid()) {
if (!getEnums()) {
return false;
}

View File

@@ -432,7 +432,9 @@ void PropertyEnumeration::Restore(Base::XMLReader &reader)
}
if (val < 0) {
Base::Console().Warning("Enumeration index %d is out of range, ignore it\n", val);
// If the enum is empty at this stage do not print a warning
if (_enum.getEnums())
Base::Console().Warning("Enumeration index %d is out of range, ignore it\n", val);
val = getValue();
}