Sfoglia il codice sorgente

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 anni fa
parent
commit
874a614455
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  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;