Fix #24095 : Crash when all staves are hidden.

Fix #24095 : Crash when all staves are hidden.

Improved tests on limit conditions.