Skip to content

Commit f047c64

Browse files
committed
displayio: further ensure just one start_terminal call
@cwalther determined that for boards with 2 displays (monster m4sk), start_terminal would be called for each one, leaking supervisor heap entries. Determine, by comparing addresses, whether the display being acted on is the first display (number zero) and do (or do not) call start_terminal. stop_terminal can safely be called multiple times, so there's no need to guard against calling it more than once. Slight behavioral change: The terminal size would follow the displays[0] size, not the displays[1] size
1 parent a57c5a1 commit f047c64

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

shared-module/displayio/Display.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@ void common_hal_displayio_display_set_rotation(displayio_display_obj_t* self, in
347347
self->core.height = tmp;
348348
}
349349
displayio_display_core_set_rotation(&self->core, rotation);
350-
supervisor_stop_terminal();
351-
supervisor_start_terminal(self->core.width, self->core.height);
350+
if (self == &displays[0].display) {
351+
supervisor_stop_terminal();
352+
supervisor_start_terminal(self->core.width, self->core.height);
353+
}
352354
if (self->core.current_group != NULL) {
353355
displayio_group_update_transform(self->core.current_group, &self->core.transform);
354356
}

shared-module/displayio/display_core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ void displayio_display_core_construct(displayio_display_core_t* self,
8585
self->bus = bus;
8686

8787

88-
supervisor_start_terminal(width, height);
88+
// (offsetof core is equal in all display types)
89+
if (self == &displays[0].display.core) {
90+
supervisor_start_terminal(width, height);
91+
}
8992

9093
self->width = width;
9194
self->height = height;

shared-module/framebufferio/FramebufferDisplay.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,10 @@ void common_hal_framebufferio_framebufferdisplay_set_rotation(framebufferio_fram
280280
self->core.height = tmp;
281281
}
282282
displayio_display_core_set_rotation(&self->core, rotation);
283-
supervisor_stop_terminal();
284-
supervisor_start_terminal(self->core.width, self->core.height);
283+
if (self == &displays[0].framebufferdisplay) {
284+
supervisor_stop_terminal();
285+
supervisor_start_terminal(self->core.width, self->core.height);
286+
}
285287
if (self->core.current_group != NULL) {
286288
displayio_group_update_transform(self->core.current_group, &self->core.transform);
287289
}

0 commit comments

Comments
 (0)