Fixed thread locking in async job callback

This commit is contained in:
Daniel P. Berrange
2007-04-13 16:01:03 -04:00
parent 81007088f7
commit 25902bfe27

View File

@ -64,32 +64,46 @@ class vmmAsyncJob(gobject.GObject):
self.topwin.destroy() self.topwin.destroy()
def pulse_pbar(self, progress="", stage=None): def pulse_pbar(self, progress="", stage=None):
self.is_pulsing = True gtk.gdk.threads_enter()
self.pbar.set_text(progress) try:
if stage is not None: self.is_pulsing = True
self.stage.set_text(stage) self.pbar.set_text(progress)
else: if stage is not None:
self.stage.set_text(_("Processing...")) self.stage.set_text(stage)
else:
self.stage.set_text(_("Processing..."))
finally:
gtk.gdk.threads_leave()
def set_pbar_fraction(self, frac, progress, stage=None): def set_pbar_fraction(self, frac, progress, stage=None):
# callback for progress meter when file size is known # callback for progress meter when file size is known
self.is_pulsing=False gtk.gdk.threads_enter()
if stage is not None: try:
self.stage.set_text(stage) self.is_pulsing=False
else: if stage is not None:
self.stage.set_text(_("Processing...")) self.stage.set_text(stage)
self.pbar.set_text(progress) else:
self.pbar.set_fraction(frac) self.stage.set_text(_("Processing..."))
self.pbar.set_text(progress)
self.pbar.set_fraction(frac)
finally:
gtk.gdk.threads_leave()
def set_pbar_done(self, progress, stage=None): def set_pbar_done(self, progress, stage=None):
#callback for progress meter when progress is done #callback for progress meter when progress is done
self.is_pulsing=False gtk.gdk.threads_enter()
if stage is not None: try:
self.stage.set_text(stage) self.is_pulsing=False
else: if stage is not None:
self.stage.set_text(_("Completed")) self.stage.set_text(stage)
self.pbar.set_text(progress) else:
self.pbar.set_fraction(1) self.stage.set_text(_("Completed"))
self.pbar.set_text(progress)
self.pbar.set_fraction(1)
finally:
gtk.gdk.threads_leave()
def exit_if_necessary(self): def exit_if_necessary(self):
gtk.gdk.threads_enter() gtk.gdk.threads_enter()