mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06: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
1 changed files with 1 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue