Fix #24095 : Crash when all staves are hidden.

Improved tests on limit conditions.
Merge pull request #612 from mgavioli/Fix_24095_Crash_on_all_staves_hidden

Fix #24095 : Crash when all staves are hidden.