Viewports: fixed a crash related to toggling visibility of different windows in a dock hierarchy. (#9631) See test "viewport_owner_change_3"