Fix a possible division by zero error

This commit is contained in:
ChrisTerBeke 2018-12-05 19:31:58 +01:00
parent 94f31378a6
commit 57efca1376
No known key found for this signature in database
GPG key ID: A49F1AB9D7E0C263

View file

@ -132,9 +132,9 @@ class PrintJobOutputModel(QObject):
@pyqtProperty(float, notify = timeElapsedChanged) @pyqtProperty(float, notify = timeElapsedChanged)
def progress(self) -> float: def progress(self) -> float:
result = self.timeElapsed / self.timeTotal time_elapsed = max(float(self.timeElapsed), 1.0) # Prevent a division by zero exception
# Never get a progress past 1.0 result = time_elapsed / self.timeTotal
return min(result, 1.0) return min(result, 1.0) # Never get a progress past 1.0
@pyqtProperty(str, notify=stateChanged) @pyqtProperty(str, notify=stateChanged)
def state(self) -> str: def state(self) -> str: