Commit c8f8dc2f authored by sumpfralle's avatar sumpfralle

fixed divide-by-zero for progress bar counter

* reported by meyergaa00: https://sourceforge.net/tracker/index.php?func=detail&aid=3304185&group_id=237831&atid=1104176


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1075 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b4a392d7
......@@ -240,6 +240,10 @@ def get_external_program_location(key):
class ProgressCounter(object):
def __init__(self, max_value, update_callback):
if max_value <= 0:
# prevent divide-by-zero in "get_percent"
self.max_value = 100
else:
self.max_value = max_value
self.current_value = 0
self.update_callback = update_callback
......@@ -256,5 +260,5 @@ class ProgressCounter(object):
return False
def get_percent(self):
return 100.0 * self.current_value / self.max_value
return min(100, max(0, 100.0 * self.current_value / self.max_value))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment