From fd7ce79f1c180cbf0a1989206713fef75672cb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Waldisp=C3=BChl?= Date: Sun, 11 Jul 2021 21:11:15 +0200 Subject: [PATCH] Fixes error when non-integer numbers were entered into duration fields --- .../src/main/resources/CHANGELOG.txt | 7 +++-- .../NullTolerantIntegerStringConverter.java | 28 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/intervalmusiccompositor.app/src/main/resources/CHANGELOG.txt b/intervalmusiccompositor.app/src/main/resources/CHANGELOG.txt index 983bad2..6faac4a 100644 --- a/intervalmusiccompositor.app/src/main/resources/CHANGELOG.txt +++ b/intervalmusiccompositor.app/src/main/resources/CHANGELOG.txt @@ -5,10 +5,11 @@ retorte laboratories (retorte.ch) IntervalMusicCompositor change log 2021-07-xx 2.10.0 [not yet released] -------------------------------------------------------------------------------- IMP #59 Inactivates process button if no compilation is possible. -FIX #61 Fixes encoding tests in some environment by explicitly states encoding. -FIX #58 Fixes crash with wrong Java version by bundling Java with the application. -FIX #60 Fixes that in advanced pattern too long breaks with break track were swallowed. +FIX #61 Failing encoding tests in some environment by explicitly states encoding. +FIX #58 Crash with wrong Java version by bundling Java with the application. +FIX #60 In advanced pattern too long breaks with break track were swallowed. FIX Settings in the starting window were not reflected in preferences dialog. +FIX Error when non-integer numbers were entered into duration fields. 2019-03-05 2.9.2 diff --git a/intervalmusiccompositor.ui.fx/src/main/java/ch/retorte/intervalmusiccompositor/ui/utils/NullTolerantIntegerStringConverter.java b/intervalmusiccompositor.ui.fx/src/main/java/ch/retorte/intervalmusiccompositor/ui/utils/NullTolerantIntegerStringConverter.java index 6c31ab6..5284398 100644 --- a/intervalmusiccompositor.ui.fx/src/main/java/ch/retorte/intervalmusiccompositor/ui/utils/NullTolerantIntegerStringConverter.java +++ b/intervalmusiccompositor.ui.fx/src/main/java/ch/retorte/intervalmusiccompositor/ui/utils/NullTolerantIntegerStringConverter.java @@ -8,19 +8,27 @@ */ public class NullTolerantIntegerStringConverter extends IntegerStringConverter { - //---- Fields + //---- Fields - private static final Integer DEFAULT_VALUE = 0; + private static final Integer DEFAULT_VALUE = 0; - //---- Methods + //---- Methods - @Override - public Integer fromString(String value) { - Integer result = super.fromString(value); - if (result == null) { - return DEFAULT_VALUE; + @Override + public Integer fromString(String value) { + Integer result = null; + + try { + result = super.fromString(value); + } catch (NumberFormatException e) { + // nop + } + + if (result == null) { + return DEFAULT_VALUE; + } + + return result; } - return result; - } }