瀏覽代碼

fix(Parsing): fix missing default-y value for credit-words causing parse error

related to mpat #62
sschmid 4 年之前
父節點
當前提交
4773487948
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      src/MusicalScore/ScoreIO/MusicSheetReader.ts

+ 5 - 4
src/MusicalScore/ScoreIO/MusicSheetReader.ts

@@ -568,10 +568,11 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
                     if (!creditChild.attribute("justify")) {
                         break;
                     }
-                    const creditJustify: string = creditChild.attribute("justify").value;
-                    const creditY: string = creditChild.attribute("default-y").value;
-                    const creditYInfo: number = parseFloat(creditY);
-                    if (creditYInfo > systemYCoordinates) {
+                    const creditJustify: string = creditChild.attribute("justify")?.value;
+                    const creditY: string = creditChild.attribute("default-y")?.value;
+                    const creditYGiven: boolean = creditY !== undefined && creditY !== null;
+                    const creditYInfo: number = creditYGiven ? parseFloat(creditY) : -1;
+                    if (creditYGiven && creditYInfo > systemYCoordinates) {
                         if (!this.musicSheet.Title) {
                             const creditSize: string = creditChild.attribute("font-size").value;
                             const titleCreditSizeInt: number = parseFloat(creditSize);