Skip to content

Commit 9842734

Browse files
committed
wxgui: Make sure to only start the flow graph once all init is done
Currently we start the flow graph in the stdframe constructor. However at that point, the frame isn't attached to the app and it's not "shown" yet which means some UI operations can still fail. This is a race condition which happens on OSX. You can reproduce it on linux as well by adding a sleep(1) after starting the flow graph. Signed-off-by: Sylvain Munaut <[email protected]>
1 parent a017004 commit 9842734

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

gr-wxgui/python/wxgui/stdgui2.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2,
4646
wx.App.__init__ (self, redirect=False)
4747

4848
def OnInit (self):
49-
frame = stdframe (self.top_block_maker, self.title, self._nstatus,
50-
self._max_noutput_items)
49+
frame = stdframe (self.top_block_maker, self.title, self._nstatus)
5150
frame.Show (True)
5251
self.SetTopWindow (frame)
52+
53+
if(self._max_noutput_items is not None):
54+
frame.top_block().start (self._max_noutput_items)
55+
else:
56+
frame.top_block().start ()
57+
5358
return True
5459

5560

5661
class stdframe (wx.Frame):
57-
def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2,
58-
max_nouts=None):
62+
def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2):
5963
# print "stdframe.__init__"
6064
wx.Frame.__init__(self, None, -1, title)
6165

@@ -69,7 +73,7 @@ def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2,
6973
self.SetMenuBar (mainmenu)
7074

7175
self.Bind (wx.EVT_CLOSE, self.OnCloseWindow)
72-
self.panel = stdpanel (self, self, top_block_maker, max_nouts)
76+
self.panel = stdpanel (self, self, top_block_maker)
7377
vbox = wx.BoxSizer(wx.VERTICAL)
7478
vbox.Add(self.panel, 1, wx.EXPAND)
7579
self.SetSizer(vbox)
@@ -85,8 +89,7 @@ def top_block (self):
8589
return self.panel.top_block
8690

8791
class stdpanel (wx.Panel):
88-
def __init__ (self, parent, frame, top_block_maker,
89-
max_nouts=None):
92+
def __init__ (self, parent, frame, top_block_maker):
9093
# print "stdpanel.__init__"
9194
wx.Panel.__init__ (self, parent, -1)
9295
self.frame = frame
@@ -97,11 +100,6 @@ def __init__ (self, parent, frame, top_block_maker,
97100
self.SetAutoLayout (True)
98101
vbox.Fit (self)
99102

100-
if(max_nouts is not None):
101-
self.top_block.start (max_nouts)
102-
else:
103-
self.top_block.start ()
104-
105103
class std_top_block (gr.top_block):
106104
def __init__ (self, parent, panel, vbox, argv):
107105
# Call the hier_block2 constructor

0 commit comments

Comments
 (0)