Skip to content

Commit

Permalink
bar: don't recreate the drawer on resize
Browse files Browse the repository at this point in the history
...instead, just resize it. If we re-create it, we'll leak the resources
attached, and that's bad.

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 25996ac commit a7f5d1c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions 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 @@ -323,9 +324,11 @@ def _configure(self, qtile: Qtile, screen: Screen, reconfigure: bool = False) ->
self.window.process_pointer_motion = self.process_pointer_motion
self.window.process_key_press = self.process_key_press

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

crashed_widgets: set[_Widget] = set()
Expand Down

0 comments on commit a7f5d1c

Please sign in to comment.