MLR122: bring_to_front is defeated by a lower z_index¶
qual reports MLR122 when Cairo is active and a conclusive
bring_to_front(target) re-adds an existing non-empty leaf root, but another
non-empty leaf has a strictly higher exact z_index.
- Default severity:
warning - Minimum confidence:
high - Implementation phase:
4 - Fix: none (suggests correcting
z_index)
Cairo stable-sorts the flattened Scene family by z_index before drawing.
Re-adding a root only changes order among equal-z ties, so it cannot put a
lower-z target in front of a strictly higher-z object.
The rule requires singleton non-empty leaf roots, exact Scene root order,
exact membership, an actual re-add of an already-present object, and exact
z_index values immediately after the call. Equal z values are valid—the
stable tie order makes bring_to_front work. Groups, branches, unknown
mutations, new-object adds, and OpenGL-only runs stay silent;
applicable_profiles lists only Cairo profiles.
Wrong:
low = Square(z_index=0)
high = Circle(z_index=3)
self.add(low, high)
self.bring_to_front(low) # still below high
Right: