mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-24 06:39:38 +08:00
Apply division by zero prevention to the denominator
Rather than the numerator, which could not cause a division by zero exception.
This commit is contained in:
parent
3dcb6b9c37
commit
9d8cf5ddde
@ -132,8 +132,7 @@ class PrintJobOutputModel(QObject):
|
||||
|
||||
@pyqtProperty(float, notify = timeElapsedChanged)
|
||||
def progress(self) -> float:
|
||||
time_elapsed = max(float(self.timeElapsed), 1.0) # Prevent a division by zero exception
|
||||
result = time_elapsed / self.timeTotal
|
||||
result = float(self.timeElapsed) / max(self.timeTotal, 1.0) # Prevent a division by zero exception.
|
||||
return min(result, 1.0) # Never get a progress past 1.0
|
||||
|
||||
@pyqtProperty(str, notify=stateChanged)
|
||||
|
Loading…
x
Reference in New Issue
Block a user