dialogxml catch nonexistent anchor at end of relative chain

This commit is contained in:
2025-05-17 10:26:15 -05:00
parent 9cde8fb78c
commit f5e84b6e37

View File

@@ -283,8 +283,12 @@ void cDialog::loadFromFile(const DialogDefn& file){
// Make sure it's not a loop!
std::vector<std::string> refs{ctrl.anchor};
while(!anchor->anchor.empty()) {
cControl* next_anchor = findControl(anchor->anchor);
if(next_anchor == nullptr){
throw xBadVal(ctrlTypeName(anchor->getType()), "anchor", anchor->anchor, 0, 0, fname);
}
refs.push_back(anchor->anchor);
anchor = findControl(anchor->anchor);
anchor = next_anchor;
if(std::find(refs.begin(), refs.end(), anchor->anchor) != refs.end()) {
throw xBadVal(ctrlTypeName(ctrl.getType()), "anchor", "<circular dependency>", 0, 0, fname);
}