mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Fix crash when entering nonsense numbers like '-'
We shouldn't accept those in the input field at all in my opinion but that is for another time. Fixes Sentry issue CURA-F5.
This commit is contained in:
parent
07e6cfa693
commit
869f26a5ba
1 changed files with 18 additions and 6 deletions
|
@ -104,7 +104,10 @@ class ImageReaderUI(QObject):
|
|||
def onWidthChanged(self, value):
|
||||
if self._ui_view and not self._disable_size_callbacks:
|
||||
if len(value) > 0:
|
||||
self._width = float(value.replace(",", "."))
|
||||
try:
|
||||
self._width = float(value.replace(",", "."))
|
||||
except ValueError: # Can happen with incomplete numbers, such as "-".
|
||||
self._width = 0
|
||||
else:
|
||||
self._width = 0
|
||||
|
||||
|
@ -117,7 +120,10 @@ class ImageReaderUI(QObject):
|
|||
def onDepthChanged(self, value):
|
||||
if self._ui_view and not self._disable_size_callbacks:
|
||||
if len(value) > 0:
|
||||
self._depth = float(value.replace(",", "."))
|
||||
try:
|
||||
self._depth = float(value.replace(",", "."))
|
||||
except ValueError: # Can happen with incomplete numbers, such as "-".
|
||||
self._depth = 0
|
||||
else:
|
||||
self._depth = 0
|
||||
|
||||
|
@ -128,15 +134,21 @@ class ImageReaderUI(QObject):
|
|||
|
||||
@pyqtSlot(str)
|
||||
def onBaseHeightChanged(self, value):
|
||||
if (len(value) > 0):
|
||||
self.base_height = float(value.replace(",", "."))
|
||||
if len(value) > 0:
|
||||
try:
|
||||
self.base_height = float(value.replace(",", "."))
|
||||
except ValueError: # Can happen with incomplete numbers, such as "-".
|
||||
self.base_height = 0
|
||||
else:
|
||||
self.base_height = 0
|
||||
|
||||
@pyqtSlot(str)
|
||||
def onPeakHeightChanged(self, value):
|
||||
if (len(value) > 0):
|
||||
self.peak_height = float(value.replace(",", "."))
|
||||
if len(value) > 0:
|
||||
try:
|
||||
self.peak_height = float(value.replace(",", "."))
|
||||
except ValueError: # Can happen with incomplete numbers, such as "-".
|
||||
self._width = 0
|
||||
else:
|
||||
self.peak_height = 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue