Explorar o código

fix undefined error (another) with drawUpToMeasureNumber set (#68)

sschmidTU %!s(int64=3) %!d(string=hai) anos
pai
achega
236f6e5e50
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      src/OpenSheetMusicDisplay/Cursor.ts

+ 4 - 2
src/OpenSheetMusicDisplay/Cursor.ts

@@ -248,9 +248,11 @@ export class Cursor implements IPlaybackListener {
 
     // y is common for both multirest and non-multirest, given the MusicSystem
     y = musicSystem.PositionAndShape.AbsolutePosition.y + musicSystem.StaffLines[0]?.PositionAndShape.RelativePosition.y ?? 0;
+    let endY: number = musicSystem.PositionAndShape.AbsolutePosition.y;
     const bottomStaffline: StaffLine = musicSystem.StaffLines[musicSystem.StaffLines.length - 1];
-    const endY: number = musicSystem.PositionAndShape.AbsolutePosition.y +
-    bottomStaffline.PositionAndShape.RelativePosition.y + bottomStaffline.StaffHeight;
+    if (bottomStaffline) {
+      endY += bottomStaffline.PositionAndShape.RelativePosition.y + bottomStaffline.StaffHeight;
+    }
     height = endY - y;
 
     // Update the graphical cursor