Fixed gnuradio-companion traceback on gtk init

Resolves: rhbz#2014797
This commit is contained in:
Jaroslav Škarvada 2021-10-19 22:32:00 +02:00
parent 51959e224c
commit fe9d16e6e6
2 changed files with 97 additions and 2 deletions

View File

@ -0,0 +1,89 @@
From 10edf66902f2926be1fa627a73b8cd6080973fc9 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 | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion
index 1d4af86b4c0..dea54a9da29 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:
From 3094aa222ecb5890a50476edf53b7d191207a508 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 dea54a9da29..c1f523d02e3 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?")

View File

@ -22,7 +22,7 @@
Name: gnuradio
Version: 3.9.3.0
Release: 1%{?alphatag:.%{alphatag}}%{?dist}
Release: 2%{?alphatag:.%{alphatag}}%{?dist}
Summary: Software defined radio framework
License: GPLv3
@ -98,6 +98,8 @@ Requires: python3-six
Requires: python3-mako
Requires: python3-click-plugins
Requires: gtk3
# https://github.com/gnuradio/gnuradio/pull/5217
Patch0: gnuradio-3.9.3.0-gtk-init.patch
%description
GNU Radio is a collection of software that when combined with minimal
@ -136,7 +138,7 @@ Requires: %{name} = %{version}-%{release}
GNU Radio examples
%prep
%setup -q -n %{name}-%{version}%{?alphatag}
%autosetup -p1 -n %{name}-%{version}%{?alphatag}
%build
# this could be dropped when f32 get retired (not counting EPEL)
@ -194,6 +196,10 @@ rm -r %{buildroot}%{_datadir}/%{name}/grc/freedesktop
%{_datadir}/gnuradio/examples
%changelog
* Tue Oct 19 2021 Jaroslav Škarvada <jskarvad@redhat.com> - 3.9.3.0-2
- Fixed gnuradio-companion traceback on gtk init
Resolves: rhbz#2014797
* Tue Oct 5 2021 Jaroslav Škarvada <jskarvad@redhat.com> - 3.9.3.0-1
- New version
Resolves: rhbz#2009572