Fix nightstand clock crashes

This commit is contained in:
Willy-JL
2023-04-06 02:18:16 +01:00
parent bba9fc4134
commit 4af2bd01ef
2 changed files with 12 additions and 21 deletions
+8 -7
View File
@@ -277,6 +277,13 @@ int32_t clock_app(void* p) {
clock_state_init(plugin_state);
notif = furi_record_open(RECORD_NOTIFICATION);
float tmpBrightness = notif->settings.display_brightness;
brightness = tmpBrightness * 100; // Keep current brightness by default
notification_message(notif, &sequence_display_backlight_enforce_on);
notification_message(notif, &led_off);
// Set system callbacks
ViewPort* view_port = view_port_alloc();
view_port_draw_callback_set(view_port, clock_render_callback, plugin_state);
@@ -301,13 +308,6 @@ int32_t clock_app(void* p) {
furi_timer_start(timer, furi_kernel_get_tick_frequency());
//FURI_LOG_D(TAG, "Timer started");
notif = furi_record_open(RECORD_NOTIFICATION);
float tmpBrightness = notif->settings.display_brightness;
brightness = tmpBrightness * 100; // Keep current brightness by default
notification_message(notif, &sequence_display_backlight_enforce_on);
notification_message(notif, &led_off);
// Main loop
PluginEvent event;
for(bool processing = true; processing;) {
@@ -354,6 +354,7 @@ int32_t clock_app(void* p) {
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_NOTIFICATION);
view_port_free(view_port);
furi_message_queue_free(plugin_state->event_queue);
furi_mutex_free(plugin_state->mutex);
@@ -61,19 +61,6 @@ static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* fl
}
#endif
static void desktop_scene_main_open_app_or_profile(Desktop* desktop, const char* path) {
do {
LoaderStatus status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, path);
if(status == LoaderStatusOk) break;
FURI_LOG_E(TAG, "loader_start failed: %d", status);
status = loader_start(desktop->loader, "Passport", NULL);
if(status != LoaderStatusOk) {
FURI_LOG_E(TAG, "loader_start failed: %d", status);
}
} while(false);
}
void desktop_scene_main_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
if(desktop->in_transition) return;
@@ -205,7 +192,10 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
break;
}
case DesktopMainEventOpenClock: {
desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Misc/Nightstand.fap"));
LoaderStatus status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("apps/Misc/Nightstand.fap"));
if(status != LoaderStatusOk) {
FURI_LOG_E(TAG, "loader_start failed: %d", status);
}
break;
}
case DesktopLockedEventUpdate: