From 0407be75444f88e1931352b2e0fe6eae0812290a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Egil=20Hoftun=20Kv=C3=A6stad?= Date: Tue, 6 Aug 2024 22:14:53 +0200 Subject: [PATCH] Reuse old value if an invalid number is used If the user inputs an invalid number (something that causes a ValueError because it can't be converted to a float), set the number back to the previous value, and discard the user input. Inputting an invalid number would crash makehuman before this fix. --- makehuman/lib/qtgui.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/makehuman/lib/qtgui.py b/makehuman/lib/qtgui.py index d356ff3a..05272018 100644 --- a/makehuman/lib/qtgui.py +++ b/makehuman/lib/qtgui.py @@ -453,7 +453,11 @@ def _enter(self): if not text: return oldValue = self.getValue() - newValue = self.fromDisplay(float(text)) + try: + newValue = self.fromDisplay(float(text)) + except ValueError: + newValue = oldValue + self.setValue(newValue) if abs(oldValue - newValue) > 1e-3: self.callEvent('onChanging', newValue)