Front: Prevent Crash on Quit and restart

This commit is contained in:
Arthur Jamet
2023-05-02 15:32:57 +01:00
parent bf4b84e1f8
commit fb9467e58e

View File

@@ -43,7 +43,7 @@ const PartitionView = (props: PartitionViewProps) => {
// Re-render manually (otherwise done by 'autoResize' option), to fix disappearing cursor
useEffect(() => {
if (osmd) {
if (osmd && osmd.IsReadyToRender()) {
osmd.render();
osmd.cursor.show();
}
@@ -57,7 +57,8 @@ const PartitionView = (props: PartitionViewProps) => {
const currentTimestamp = new Fraction(props.timestamp, 1000, undefined, true);
let previousCursorPosition = -1;
let currentCursorPosition = osmd.cursor.cursorElement.offsetLeft;
while(osmd.cursor.NotesUnderCursor().at(0)!.getAbsoluteTimestamp().lt(currentTimestamp) && !osmd.cursor.iterator.EndReached) {
while(osmd.cursor.NotesUnderCursor().at(0)?.getAbsoluteTimestamp().lt(currentTimestamp) && !osmd.cursor.iterator.EndReached) {
// console.log(osmd.cursor.NotesUnderCursor().at(0)!.getAbsoluteTimestamp(), osmd.cursor.NotesUnderCursor().at(0)!.Length);
previousCursorPosition = currentCursorPosition;
osmd.cursor.next();
osmd.cursor.show();