1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

core: wait for the default layout after closing a workflow

Fixes #469
This commit is contained in:
Jan Pochyla 2019-09-02 12:52:02 +02:00
parent ccb926af53
commit 355cebf8bf
2 changed files with 11 additions and 1 deletions

View File

@ -319,3 +319,8 @@ class Layout(Component):
# TODO: remove the busy loop
yield sleep
self.dispatch(RENDER, 0, 0)
def wait_until_layout_is_running():
while not layout_chan.takers:
yield

View File

@ -36,7 +36,7 @@ reads the message's header. When the message type is known the first handler is
"""
import protobuf
from trezor import log, loop, messages, utils, workflow
from trezor import log, loop, messages, utils, workflow, ui
from trezor.messages import FailureType
from trezor.messages.Failure import Failure
from trezor.wire import codec_v1
@ -347,6 +347,11 @@ async def handle_session(iface: WireInterface, session_id: int) -> None:
# registered it before.
if wf_task is not None:
workflow.on_close(wf_task)
# If a default workflow is on, make sure we do not race
# against the layout that is inside.
# TODO: this is very hacky and complects wire with the ui
if workflow.default_task is not None:
await ui.wait_until_layout_is_running()
if res_msg is not None:
# Either the workflow returned a response, or we created one.