musescore/MuseScore — pull request #264 by heuchi (2013-03-15 13:28:25+00:00)
Title: Fix #16506 Former key signature isn't restored after Undo Transpose 

When transposing key signatures Score::transposeKeys() updates the keymap in transpose.cpp:417
(*km)[tick] = nKey;
This is not stored in the undo stack.

While undo resets the actual KeySigs, layout will later change them back to match the (old) keymap.
I added a call to setKey() in ChangeKeySig::flip() to make sure the keymap matches all key signature changes.