Skip to content

Commit

Permalink
remember to finish all surfaces when finalizing
Browse files Browse the repository at this point in the history
We need to .finalize() all surfaces when we release them, or they may keep
resources allocated in their respective backends.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
  • Loading branch information
tych0 committed May 26, 2024
1 parent b2220d2 commit 25996ac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libqtile/backend/base/drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ def __init__(self, qtile: Qtile, win: Internal, width: int, height: int):

def finalize(self):
"""Destructor/Clean up resources"""
self.background_surface = None
self.surface = None
self.last_surface = None
if hasattr(self, "surface"):
self.surface.finish()
delattr(self, "surface")
if hasattr(self, "last_surface"):
self.last_surface.finish()
delattr(self, "last_surface")
self.ctx = None

@property
Expand Down Expand Up @@ -109,6 +112,9 @@ def height(self, height: int):

def _reset_surface(self):
"""This creates a fresh surface and cairo context."""
if hasattr(self, "surface"):
self.surface.finish()

self.surface = cairocffi.RecordingSurface(
cairocffi.CONTENT_COLOR_ALPHA,
None,
Expand Down

0 comments on commit 25996ac

Please sign in to comment.