Skip to content
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

only add circuitpython_splash to display if it's not in another group #7829

Merged
merged 2 commits into from
Apr 5, 2023

Conversation

FoamyGuy
Copy link
Collaborator

@FoamyGuy FoamyGuy commented Apr 3, 2023

resolves #7824

Tested successfully on Monster M4sk

Not sure if we need to guard more cautiously against circuitpython_splash being null or not having in_group. This code assumes it will exist and have that property to check. It does seem safe after testing on Monster M4sk but I don't know if there are other scenarios that could be problematic.

@@ -136,7 +136,9 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,

// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
common_hal_displayio_display_set_root_group(self, &circuitpython_splash);
if (!circuitpython_splash.in_group) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks fine, but I noticed a few lines later it checks if root_group is NULL and if so assigns it to circuitpython_splash with no checks and not using the function. Not sure how that may affect anything. But your check on its own looks good.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you talking about when calling display.show(None) ? It uses common_hal_displayio_display_show which does a few checks, including if the group is already in a group, and returns False when those checks fail. That return is checked and an exception is raised in the shared-bindings part:

bool ok = common_hal_displayio_display_show(self, group);
if (!ok) {
mp_raise_ValueError(translate("Group already used"));
}

Maybe it could use common_hal_displayio_display_set_root_group instead. (show() is deprecated anyway).

@FoamyGuy
Copy link
Collaborator Author

FoamyGuy commented Apr 5, 2023

The latest commit adds the same check as the original commit but to a different section of code inside reset_display() which had caused trouble raised by #7472

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you!

@tannewt tannewt merged commit 34a525a into adafruit:main Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Group already in use when instantiating 2 displays
4 participants