Sometimes, the pending events can get into an infinite loop of causing more events to be handled; this fix makes it finite
svn: r13778
This commit is contained in:
parent
b1254d7820
commit
58dc389e48
@ -52,6 +52,7 @@ import gobject
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.utils
|
import gen.utils
|
||||||
|
from gui.utils import process_pending_events
|
||||||
import config
|
import config
|
||||||
from BasicUtils import name_displayer
|
from BasicUtils import name_displayer
|
||||||
import const
|
import const
|
||||||
@ -404,8 +405,7 @@ class DisplayState(gen.utils.Callback):
|
|||||||
self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||||
else:
|
else:
|
||||||
self.window.window.set_cursor(None)
|
self.window.window.set_cursor(None)
|
||||||
while gtk.events_pending():
|
process_pending_events()
|
||||||
gtk.main_iteration()
|
|
||||||
|
|
||||||
def set_open_widget(self, widget):
|
def set_open_widget(self, widget):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
@ -443,18 +443,14 @@ class DisplayState(gen.utils.Callback):
|
|||||||
else:
|
else:
|
||||||
name = _("No active person")
|
name = _("No active person")
|
||||||
self.status.push(self.status_id, name)
|
self.status.push(self.status_id, name)
|
||||||
|
process_pending_events()
|
||||||
while gtk.events_pending():
|
|
||||||
gtk.main_iteration()
|
|
||||||
|
|
||||||
def pulse_progressbar(self, value):
|
def pulse_progressbar(self, value):
|
||||||
self.progress.set_fraction(min(value/100.0, 1.0))
|
self.progress.set_fraction(min(value/100.0, 1.0))
|
||||||
self.progress.set_text("%d%%" % value)
|
self.progress.set_text("%d%%" % value)
|
||||||
while gtk.events_pending():
|
process_pending_events()
|
||||||
gtk.main_iteration()
|
|
||||||
|
|
||||||
def status_text(self, text):
|
def status_text(self, text):
|
||||||
self.status.pop(self.status_id)
|
self.status.pop(self.status_id)
|
||||||
self.status.push(self.status_id, text)
|
self.status.push(self.status_id, text)
|
||||||
while gtk.events_pending():
|
process_pending_events()
|
||||||
gtk.main_iteration()
|
|
||||||
|
@ -271,3 +271,15 @@ def open_file_with_default_application( file_path ):
|
|||||||
if os.path.isfile(prog):
|
if os.path.isfile(prog):
|
||||||
os.spawnvpe(os.P_NOWAIT, prog, [prog, norm_path], os.environ)
|
os.spawnvpe(os.P_NOWAIT, prog, [prog, norm_path], os.environ)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def process_pending_events(max_count=10):
|
||||||
|
"""
|
||||||
|
Process pending events, but don't get into an infinite loop.
|
||||||
|
"""
|
||||||
|
import gtk
|
||||||
|
count = 0
|
||||||
|
while gtk.events_pending():
|
||||||
|
gtk.main_iteration()
|
||||||
|
count += 1
|
||||||
|
if count >= max_count:
|
||||||
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user