fix #27921

Fixed one bug, found new.
These bugs with StaffText and InstrumentChange are related to my current work on assigning midi channels to instruments. I wouldn't write about them to an issue tracker, they can disappear or can be fixed by me.
we prefer static_cast<Segment*> instead of (Segment*). Can you change and squash?