diff options
author | Sylvain Munaut <246tnt@gmail.com> | 2013-10-13 17:19:37 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2013-10-13 17:20:19 -0700 |
commit | d5f0cec440ef2848992ce0ae34bfe73bb0c9772a (patch) | |
tree | b5e806e3095e664aa8520f30d398179e1aae0c96 | |
parent | fb9ad6e707e09c3761762aad2a6673ac5b6c7e2e (diff) |
wxgui: Allow Linux/X11 apps to be thread-safe
Call XInitThreads as first Xlib call
-rw-r--r-- | gr-wxgui/python/wxgui/stdgui2.py | 9 | ||||
-rw-r--r-- | grc/python/flow_graph.tmpl | 10 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gr-wxgui/python/wxgui/stdgui2.py b/gr-wxgui/python/wxgui/stdgui2.py index 71436d72c4..b38589988e 100644 --- a/gr-wxgui/python/wxgui/stdgui2.py +++ b/gr-wxgui/python/wxgui/stdgui2.py @@ -21,6 +21,8 @@ '''A simple wx gui for GNU Radio applications''' +import ctypes +import os import wx import sys from gnuradio import gr @@ -33,6 +35,13 @@ class stdapp (wx.App): self.title = title self._nstatus = nstatus self._max_noutput_items = max_noutput_items + # If we're on Linux, also enable multi-threading Xlib access + if os.name == 'posix': + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" # All our initialization must come before calling wx.App.__init__. # OnInit is called from somewhere in the guts of __init__. wx.App.__init__ (self, redirect=False) diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index 8b44f55126..3e9520a14f 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -275,6 +275,16 @@ $short_id#slurp #end def #if $generate_options != 'hb' if __name__ == '__main__': + #if $generate_options in ('wx_gui', 'qt_gui') + import ctypes + import os + if os.name == 'posix': + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + #end if parser = OptionParser(option_class=eng_option, usage="%prog: [options]") #set $params_eq_list = list() #for $param in $parameters |