Преглед на файлове

fix(GraphicalVoiceEntry): `parentStaffEntry` undefined

There are cases in which `parentStaffEntry` is undefined (and `parentVoiceEntry` as well) leading to an exception. Therefore, I create a default set of engraving rules. I cannot think of a way to retrieve the instance of the engraving rules at that point. Do I miss anything?
Daniel Fürst преди 5 години
родител
ревизия
874a614455
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2 1
      src/MusicalScore/Graphical/GraphicalVoiceEntry.ts

+ 2 - 1
src/MusicalScore/Graphical/GraphicalVoiceEntry.ts

@@ -20,7 +20,8 @@ export class GraphicalVoiceEntry extends GraphicalObject {
         this.parentStaffEntry = parentStaffEntry;
         this.PositionAndShape = new BoundingBox(this, parentStaffEntry ? parentStaffEntry.PositionAndShape : undefined, true);
         this.notes = [];
-        this.rules = parentStaffEntry.parentMeasure.parentSourceMeasure.Rules;
+        this.rules = parentStaffEntry ?
+                        parentStaffEntry.parentMeasure.parentSourceMeasure.Rules : new EngravingRules();
     }
 
     public parentVoiceEntry: VoiceEntry;