Client *c = this;
while (c->_transient_for) {
c = c->_transient_for;
+ if (c == this) break; // circular?
if (c->_modal_child) break; // already has a modal child
c->_modal_child = this;
}
c = this;
while (c->_transient_for) {
c = c->_transient_for;
+ if (c == this) break; // circular?
if (c->_modal_child != this) break; // has a different modal child
+ if (c == replacement) break; // found the replacement itself
c->_modal_child = replacement;
}
}