Jelajahi Sumber

fix occasional null error in ChordSymbolContainer

sschmid 5 tahun lalu
induk
melakukan
808fa916ec

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

@@ -6,6 +6,7 @@ import {BoundingBox} from "./BoundingBox";
 import {GraphicalObject} from "./GraphicalObject";
 import {PointF2D} from "../../Common/DataObjects/PointF2D";
 import {EngravingRules} from "./EngravingRules";
+import {FontStyles} from "../../Common";
 
 export class GraphicalChordSymbolContainer extends GraphicalObject {
     private chordSymbolContainer: ChordSymbolContainer;
@@ -29,7 +30,7 @@ export class GraphicalChordSymbolContainer extends GraphicalObject {
     private calculateLabel(textHeight: number, transposeHalftones: number): void {
         const text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones);
         const label: Label = new Label(text);
-        label.fontStyle = this.rules.DefaultFontStyle;
+        label.fontStyle = this.rules?.DefaultFontStyle ?? FontStyles.Regular; // TODO seems like rules are undefined sometimes
         this.graphicalLabel = new GraphicalLabel(label, textHeight, TextAlignmentEnum.CenterBottom, this.rules, this.boundingBox);
         this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(0.0, 0.0);
     }

+ 1 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowGraphicalSymbolFactory.ts

@@ -175,7 +175,7 @@ export class VexFlowGraphicalSymbolFactory implements IGraphicalSymbolFactory {
                                                 graphicalStaffEntry.PositionAndShape,
                                                 rules.ChordSymbolTextHeight,
                                                 transposeHalftones,
-                                                graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules
+                                                graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules // TODO undefined sometimes
                                                 );
             const graphicalLabel: GraphicalLabel = graphicalChordSymbolContainer.GetGraphicalLabel;
             graphicalLabel.PositionAndShape.RelativePosition.y -= rules.ChordSymbolYOffset;