From 4de91e691fecb5abc3a842c9e25112de0db67e26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20M=C3=BCller?= <mmueller@gnuradio.org>
Date: Tue, 19 Oct 2021 19:37:38 +0200
Subject: [PATCH 1/2] GRC: don't rely on GUI to inform about failure to
initialize GUI
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
---
grc/scripts/gnuradio-companion | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion
index 1d4af86b4c0..d0757e87eac 100755
--- a/grc/scripts/gnuradio-companion
+++ b/grc/scripts/gnuradio-companion
@@ -37,10 +37,16 @@ def die(error, message):
)
d.set_title(type(error).__name__)
d.run()
- exit(1)
+ sys.exit(1)
except ImportError:
- exit(type(error).__name__ + '\n\n' + msg)
-
+ sys.exit(type(error).__name__ + '\n\n' + msg)
+ except Exception as _exception:
+ print(
+ "While trying to display an error message, another error occurred",
+ file=sys.stderr)
+ print(_exception, file=sys.stderr)
+ print("The original error message follows.", file=sys.stderr)
+ sys.exit(type(error).__name__ + '\n\n' + msg)
def check_gtk():
try:
@@ -82,7 +88,7 @@ def run_main():
print("Running from source tree")
sys.path.insert(1, script_path[:-len(source_tree_subpath)])
from grc.main import main
- exit(main())
+ sys.exit(main())
if __name__ == '__main__':
From 5b43f4645b47f3ff862b1b645cfa6d0fb8f1e8e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20M=C3=BCller?= <mmueller@gnuradio.org>
Date: Tue, 19 Oct 2021 19:49:14 +0200
Subject: [PATCH 2/2] GRC: be tolerant against Gtk.init_check failure, which
seems to be flimsy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
---
grc/scripts/gnuradio-companion | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion
index d0757e87eac..2f299744717 100755
--- a/grc/scripts/gnuradio-companion
+++ b/grc/scripts/gnuradio-companion
@@ -7,7 +7,6 @@
import os
import sys
-import warnings
GR_IMPORT_ERROR_MESSAGE = """\
@@ -50,15 +49,20 @@ def die(error, message):
def check_gtk():
try:
- warnings.filterwarnings("error")
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('PangoCairo', '1.0')
gi.require_foreign('cairo', 'Context')
from gi.repository import Gtk
- Gtk.init_check()
- warnings.filterwarnings("always")
+ success = Gtk.init_check()[0]
+ if not success:
+ # Don't display a warning dialogue. This seems to be a Gtk bug. If it
+ # still can display warning dialogues, it does probably work!
+ print(
+ "Gtk init_check failed. GRC might not be able to start a GUI.",
+ file=sys.stderr)
+
except Exception as err:
die(err, "Failed to initialize GTK. If you are running over ssh, "
"did you enable X forwarding and start ssh with -X?")