fix #18693 : Cut-n-paste of a measure containing a slur causes a crash

Added support for finding the nth grace note (or grace level as defined by getGraceSegment). Using this to test for grace notes in undo.cpp. This fixes the bug and which is not really related to cut and paste but the two grace notes in the beginning.

This pull request only fixes the slur problem with several grace notes, but e.g. tie has the same problem, so I will fix that also if this is the right way to go.