Skip to content

Free the bitmap when set to empty string #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def _reset_text(
for _ in self._local_group:
self._local_group.pop(0)

# Free the bitmap and tilegrid since they are removed
self._bitmap = None
self._tilegrid = None

else: # The text string is not empty, so create the Bitmap and TileGrid and
# append to the self Group

Expand Down Expand Up @@ -200,9 +204,7 @@ def _reset_text(
# Place the text into the Bitmap
self._place_text(
self._bitmap,
text
if self._label_direction != "RTL"
else "".join(reversed(self._text)),
text if self._label_direction != "RTL" else "".join(reversed(text)),
self._font,
self._padding_left - x_offset,
self._padding_top + y_offset,
Expand Down