From fb9467e58eff1fe43f93cb4b616c34ec99a620d9 Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Tue, 2 May 2023 15:32:57 +0100 Subject: [PATCH] Front: Prevent Crash on Quit and restart --- front/components/PartitionView.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front/components/PartitionView.tsx b/front/components/PartitionView.tsx index bc4bd25..24ba437 100644 --- a/front/components/PartitionView.tsx +++ b/front/components/PartitionView.tsx @@ -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();