From 9c3982d4ffc81364839cc37c57572be562bb47dc Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 26 Sep 2021 19:13:19 +0100 Subject: [GTKUI] Fix piecesbar crashing when enabled When enabled in preferences the piecesbar was crashing the application. This was narrowed down to an issue with text_font property and there was a suggestion that the PangoFontDescription should be freed after getting the result from get_style_context. Fixed by creating a copy of the PangoFontDescription Refs: * https://trac.wxwidgets.org/ticket/15697#comment:1 --- deluge/ui/gtk3/piecesbar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deluge/ui/gtk3/piecesbar.py b/deluge/ui/gtk3/piecesbar.py index ba03e5520..549f9c048 100644 --- a/deluge/ui/gtk3/piecesbar.py +++ b/deluge/ui/gtk3/piecesbar.py @@ -14,6 +14,7 @@ from math import pi import gi # isort:skip (Version check required before import). gi.require_version('PangoCairo', '1.0') # NOQA: E402 +gi.require_foreign('cairo') # NOQA: E402 gi.require_version('cairo', '1.0') # NOQA: E402 # isort:imports-thirdparty @@ -38,7 +39,8 @@ class PiecesBar(DrawingArea): # Get progress bar styles, in order to keep font consistency pb = ProgressBar() pb_style = pb.get_style_context() - self.text_font = pb_style.get_property('font', StateFlags.NORMAL) + # Get a copy of Pango.FontDescription since original needs freed. + self.text_font = pb_style.get_property('font', StateFlags.NORMAL).copy() self.text_font.set_weight(Weight.BOLD) # Done with the ProgressBar styles, don't keep refs of it del pb, pb_style -- cgit