Skip to content

Commit

Permalink
bar: finalize drawer before recreating it
Browse files Browse the repository at this point in the history
If the drawer previously existed, we need to .finalize() it, or we'll leak
its resources.

The comment about the stated reason for this is a little strange: we have
width and height setters here, can we not just set them and not re-create
the drawer at all? Thoughts welcome.

This is another leak that I found while looking for the source of #4821.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
  • Loading branch information
tych0 committed May 26, 2024
1 parent b2220d2 commit b42eee5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libqtile/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import asyncio
from typing import Any

from libqtile.backend.base import Internal, WindowType
from libqtile.backend.base import Drawer, Internal, WindowType
from libqtile.command.base import ItemT
from libqtile.config import Screen
from libqtile.core.manager import Qtile
Expand Down Expand Up @@ -200,6 +200,7 @@ def __init__(self, widgets: list[_Widget], size: int, **config: Any) -> None:
# bar as python is referring to the same list.
self.widgets = widgets.copy()
self.window: Internal | None = None
self.drawer: Drawer
self._configured = False
self._draw_queued = False
self.future: asyncio.Handle | None = None
Expand Down Expand Up @@ -325,6 +326,8 @@ def _configure(self, qtile: Qtile, screen: Screen, reconfigure: bool = False) ->

# We create a new drawer even if there's already a window to ensure the
# drawer is the right size.
if hasattr(self, "drawer"):
self.drawer.finalize()
self.drawer = self.window.create_drawer(width, height)
self.drawer.clear(self.background)

Expand Down

0 comments on commit b42eee5

Please sign in to comment.