summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2021-09-26 19:13:19 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2021-10-03 17:20:22 +0100
commit9c3982d4ffc81364839cc37c57572be562bb47dc (patch)
tree8451526d17f5800e95024209d9ad7ac34f00418e
parent88fc21e9938e08827751509d4da20b9dad44bf92 (diff)
downloaddeluge-9c3982d4ffc81364839cc37c57572be562bb47dc.tar.gz
deluge-9c3982d4ffc81364839cc37c57572be562bb47dc.tar.bz2
deluge-9c3982d4ffc81364839cc37c57572be562bb47dc.zip
[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
-rw-r--r--deluge/ui/gtk3/piecesbar.py4
1 files changed, 3 insertions, 1 deletions
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