From 64e263a1af9b6310fc0913be1e141cc4c86894a5 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 24 Sep 2022 23:34:50 +0200 Subject: [PATCH] Fix an unexplained crash encountered in the wild For some reason, 'subtype' can be null. Perhaps because the keyboard is started before the IMM is ready. --- srcs/juloo.keyboard2/Keyboard2.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index ccc4be5..bb51999 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -147,8 +147,16 @@ public class Keyboard2 extends InputMethodService else { InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype(); - refreshSubtypeLayout(subtype); - refreshAccentsOption(imm, subtype); + if (subtype == null) + { + // On some rare cases, [subtype] is null. + refreshSubtypeLegacyFallback(); + } + else + { + refreshSubtypeLayout(subtype); + refreshAccentsOption(imm, subtype); + } } _config.shouldOfferSwitchingToProgramming = _config.programming_layout != -1 &&