diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2021-01-08 16:31:43 +0100 |
---|---|---|
committer | Martin Braun <martin@gnuradio.org> | 2021-01-12 02:54:42 -0800 |
commit | 1e661918ad4fd096b2c990354c316602813246c7 (patch) | |
tree | 3265c7f246cbc195eb9119a15e53247c99005e47 | |
parent | 9f8ed5bb5decdcc6905e4a8cbd22ac31bca619a7 (diff) |
grc: In flowgraph, use closeEvent() to stop flow graph and not aboutToQuit
So originally I introduced the aboutToQuit() stuff in the hope to
cleanly shutdown the flow graph, including the Qt widgets blocks
before the Qt stuff is torn down.
Turns out that in aboutToQuit some stuff is already invalid, especially
in OpenGL and so causes SegFault on exit.
Instead this patch modify the logic so that we stop the flow graph before
Qt even begin disabling things.
The two shutdown path that exits are :
- The sig_handler in case we get TERM or INT signals
- The closeEvent() of the main window
This makes sure that both path call tb.stop() tb.wait() and also
any snippet 'main_after_stop'.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r-- | grc/core/generator/flow_graph.py.mako | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/grc/core/generator/flow_graph.py.mako b/grc/core/generator/flow_graph.py.mako index e79bfa6f29..fd68623e88 100644 --- a/grc/core/generator/flow_graph.py.mako +++ b/grc/core/generator/flow_graph.py.mako @@ -257,6 +257,9 @@ gr.io_signature.makev(${len(io_sigs)}, ${len(io_sigs)}, [${', '.join(size_strs)} def closeEvent(self, event): self.settings = Qt.QSettings("GNU Radio", "${class_name}") self.settings.setValue("geometry", self.saveGeometry()) + self.stop() + self.wait() + ${'snippets_main_after_stop(self)' if snippets['main_after_stop'] else ''} event.accept() % if flow_graph.get_option('qt_qss_theme'): @@ -371,6 +374,9 @@ def main(top_block_cls=${class_name}, options=None): tb.show() def sig_handler(sig=None, frame=None): + tb.stop() + tb.wait() + ${'snippets_main_after_stop(tb)' if snippets['main_after_stop'] else ''} Qt.QApplication.quit() signal.signal(signal.SIGINT, sig_handler) @@ -380,11 +386,6 @@ def main(top_block_cls=${class_name}, options=None): timer.start(500) timer.timeout.connect(lambda: None) - def quitting(): - tb.stop() - tb.wait() - ${'snippets_main_after_stop(tb)' if snippets['main_after_stop'] else ''} - qapp.aboutToQuit.connect(quitting) % for m in monitors: % if m.params['en'].get_value() == 'True': tb.${m.name}.start() |