docs(core): document expected `layout_factory()` behavior
What changed, and why it matters
This commit only adds a documentation comment to a Python file, reminding programmers that a helper function must create a fresh layout object every time it is called. No code behavior was changed, so there is no security issue in the commit itself.
No action required; this is a documentation-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single docstring/note inside Details.from_layout() in core/src/trezor/ui/layouts/menu.py stating that layout_factory() must create a new layout on each invocation. The surrounding code is unchanged. The note is purely informational for future developers and does not alter execution, validation, or memory management.
Changed components
core/src/trezor/ui/layouts/menu.pyInspect captured patch +2 / −0
diff --git a/core/src/trezor/ui/layouts/menu.py b/core/src/trezor/ui/layouts/menu.py
index a9adafe7..eebf4447 100644
--- a/core/src/trezor/ui/layouts/menu.py
+++ b/core/src/trezor/ui/layouts/menu.py
@@ -49,6 +49,8 @@ class Details:
def from_layout(
cls, name: str, layout_factory: Callable[[], trezorui_api.LayoutObj[T]]
) -> Self:
+ """IMPORTANT: `layout_factory()` MUST create a new layout on each invocation."""
+
async def _interact() -> T:
with layout_factory() as obj:
# details' layout is de-allocated after interact() returns.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.