From 3d6ada615f0b576f617cc6347c624a6bd84cf30f Mon Sep 17 00:00:00 2001 From: dcog989 Date: Mon, 7 Sep 2026 10:36:40 +0100 Subject: [PATCH] fix: guard caption lookup when no window match found getHighestCaptionScore and getHighestCaptionScoreIgnoreNumbers evaluated windowData.saved[highestIndex].caption before the log() early-return, causing "Cannot read property 'caption' of undefined" on boot when no saved window matched (highestIndex stays -1). Guard the access with a bounds check. --- src/contents/ui/main.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml index 7083ea9..a0a83f9 100644 --- a/src/contents/ui/main.qml +++ b/src/contents/ui/main.qml @@ -306,7 +306,7 @@ Item { } } - log('getHighestCaptionScore highestScore: ' + highestScore + ' caption client: ' + client.caption + ' caption save: ' + windowData.saved[highestIndex].caption); + log('getHighestCaptionScore highestScore: ' + highestScore + ' caption client: ' + client.caption + ' caption save: ' + (highestIndex >= 0 ? windowData.saved[highestIndex].caption : 'none')); return returnIndex ? [highestScore, highestIndex] : highestScore; } @@ -338,7 +338,7 @@ Item { } } - log('getHighestCaptionScoreIgnoreNumbers highestScore: ' + highestScore + ' caption client: ' + client.caption + ' caption save: ' + windowData.saved[highestIndex].caption); + log('getHighestCaptionScoreIgnoreNumbers highestScore: ' + highestScore + ' caption client: ' + client.caption + ' caption save: ' + (highestIndex >= 0 ? windowData.saved[highestIndex].caption : 'none')); return returnIndex ? [highestScore, highestIndex] : highestScore; }