From 610504848493918cf206726a314ea118e7b585e8 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 21 Feb 2026 22:45:16 +0000 Subject: [PATCH] Fix IndexOutOfBoundsException in MetronomeInter when equalIndex is 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When OCR reads a tempo marking where the note symbol is in a separate word before "=" (e.g. "♩ = 100"), equalIndex can be 0. The code at line 942 then tries get(equalIndex - 1) = get(-1), which throws IndexOutOfBoundsException: Index -1. Adding a bounds check (equalIndex > 0) lets execution fall through to the existing reporter.alert() handler on line 948, which raises a ParsingException caught at line 985. Fixes #812 --- .../main/java/org/audiveris/omr/sig/inter/MetronomeInter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/audiveris/omr/sig/inter/MetronomeInter.java b/app/src/main/java/org/audiveris/omr/sig/inter/MetronomeInter.java index 3c8ebda48..b7f0cf3af 100644 --- a/app/src/main/java/org/audiveris/omr/sig/inter/MetronomeInter.java +++ b/app/src/main/java/org/audiveris/omr/sig/inter/MetronomeInter.java @@ -939,7 +939,7 @@ public static MetronomeInter create (TextLine line, ctx.noteWord = line.getWords().get(equalIndex); ctx.charIndex = ctx.noteWord.getValue().indexOf(noteStr); - if (ctx.charIndex == -1) { + if (ctx.charIndex == -1 && equalIndex > 0) { // Note not found, let's look in the word before ctx.noteWord = line.getWords().get(equalIndex - 1); ctx.charIndex = ctx.noteWord.getValue().indexOf(noteStr);