[gjc] gtkexcepthook is thread-aware
This commit is contained in:
parent
ceb71387f5
commit
b662ae401f
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import threading
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import pango
|
import pango
|
||||||
|
@ -32,18 +33,15 @@ from common import helpers
|
||||||
from common import i18n
|
from common import i18n
|
||||||
|
|
||||||
_ = i18n._
|
_ = i18n._
|
||||||
_exception_in_progress = False
|
_exception_in_progress = threading.Lock()
|
||||||
|
|
||||||
def _info(type, value, tb):
|
def _info(type, value, tb):
|
||||||
global _exception_in_progress
|
if not _exception_in_progress.acquire(False):
|
||||||
if _exception_in_progress:
|
|
||||||
# Exceptions have piled up, so we use the default exception
|
# Exceptions have piled up, so we use the default exception
|
||||||
# handler for such exceptions
|
# handler for such exceptions
|
||||||
_excepthook_save(type, value, tb)
|
_excepthook_save(type, value, tb)
|
||||||
return
|
return
|
||||||
|
|
||||||
_exception_in_progress = True
|
|
||||||
|
|
||||||
dialog = dialogs.HigDialog(None, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE,
|
dialog = dialogs.HigDialog(None, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE,
|
||||||
_('A programming error has been detected'),
|
_('A programming error has been detected'),
|
||||||
_('It probably is not fatal, but should be reported '
|
_('It probably is not fatal, but should be reported '
|
||||||
|
@ -91,7 +89,7 @@ def _info(type, value, tb):
|
||||||
else:
|
else:
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
_exception_in_progress = False
|
_exception_in_progress.release()
|
||||||
|
|
||||||
if not sys.stderr.isatty(): # gdb/kdm etc if we use startx this is not True
|
if not sys.stderr.isatty(): # gdb/kdm etc if we use startx this is not True
|
||||||
#FIXME: maybe always show dialog?
|
#FIXME: maybe always show dialog?
|
||||||
|
@ -103,4 +101,3 @@ if __name__ == '__main__':
|
||||||
_excepthook_save = sys.excepthook
|
_excepthook_save = sys.excepthook
|
||||||
sys.excepthook = _info
|
sys.excepthook = _info
|
||||||
print x # this always tracebacks
|
print x # this always tracebacks
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue