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:
Ghostkeeper 2019-01-28 16:40:45 +01:00
parent 3dcb6b9c37
commit 9d8cf5ddde
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276

View File

@ -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)