Clear stale exception in _exec_result; more status_bar fixups

This commit is contained in:
Dan Halbert 2022-09-01 19:10:16 -04:00
parent 2fa671c0f8
commit 2c42a48962
3 changed files with 23 additions and 10 deletions

4
main.c
View File

@ -458,6 +458,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
// Finished executing python code. Cleanup includes filesystem flush and a board reset.
cleanup_after_vm(heap, _exec_result.exception);
_exec_result.exception = NULL;
// If a new next code file was set, that is a reason to keep it (obviously). Stuff this into
// the options because it can be treated like any other reason-for-stickiness bit. The
@ -841,6 +842,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
port_post_boot_py(true);
cleanup_after_vm(heap, _exec_result.exception);
_exec_result.exception = NULL;
port_post_boot_py(false);
@ -992,7 +994,7 @@ int __attribute__((used)) main(void) {
supervisor_workflow_start();
#if CIRCUITPY_STATUS_BAR
supervisor_status_bar_start();
supervisor_status_bar_request_update(true);
#endif
// Boot script is finished, so now go into REPL or run code.py.

View File

@ -40,6 +40,11 @@ bool shared_module_supervisor_status_bar_get_console(supervisor_status_bar_obj_t
}
void shared_module_supervisor_status_bar_set_console(supervisor_status_bar_obj_t *self, bool enabled) {
if (self->console == enabled) {
// Do nothing if not changing the state.
return;
}
if (self->written) {
// Clear before changing state. If disabling, will remain cleared.
supervisor_status_bar_clear();
@ -57,6 +62,11 @@ bool shared_module_supervisor_status_bar_get_display(supervisor_status_bar_obj_t
#if CIRCUITPY_TERMINALIO
void shared_module_supervisor_status_bar_set_display(supervisor_status_bar_obj_t *self, bool enabled) {
if (self->display == enabled) {
// Do nothing if not changing the state.
return;
}
if (self->written) {
// Clear before changing state. If disabling, will remain cleared.
terminalio_terminal_clear_status_bar(&supervisor_terminal);

View File

@ -50,13 +50,6 @@ static background_callback_t status_bar_background_cb;
static bool _forced_dirty = false;
static bool _suspended = false;
void supervisor_status_bar_init(void) {
shared_module_supervisor_status_bar_obj.console = true;
shared_module_supervisor_status_bar_obj.display = true;
shared_module_supervisor_status_bar_obj.update_in_progress = false;
shared_module_supervisor_status_bar_obj.written = false;
}
// Clear if possible, but give up if we can't do it now.
void supervisor_status_bar_clear(void) {
if (!_suspended) {
@ -121,8 +114,6 @@ static void status_bar_background(void *data) {
}
void supervisor_status_bar_start(void) {
status_bar_background_cb.fun = status_bar_background;
status_bar_background_cb.data = NULL;
supervisor_status_bar_request_update(true);
}
@ -141,3 +132,13 @@ void supervisor_status_bar_resume(void) {
_suspended = false;
supervisor_status_bar_request_update(false);
}
void supervisor_status_bar_init(void) {
status_bar_background_cb.fun = status_bar_background;
status_bar_background_cb.data = NULL;
shared_module_supervisor_status_bar_obj.console = true;
shared_module_supervisor_status_bar_obj.display = true;
shared_module_supervisor_status_bar_obj.update_in_progress = false;
shared_module_supervisor_status_bar_obj.written = false;
}