mirror of
https://protopirate.net/ProtoPirate/ProtoPirate.git
synced 2026-09-25 16:13:35 +00:00
Merge pull request 'Fix all the Crashes after using the Config Menu.' (#49) from RalphWiggum/ProtoPirate:config_crashes into main
Reviewed-on: http://protopirate.net/ProtoPirate/ProtoPirate/pulls/49 Reviewed-by: MMX <mmx@no-reply.protopirate.net>
This commit is contained in:
@@ -114,3 +114,11 @@ void protopirate_views_free(ProtoPirateApp* app) {
|
||||
app->protopirate_receiver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void protopirate_variable_item_list_free(ProtoPirateApp* app) {
|
||||
if(app->variable_item_list) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, ProtoPirateViewVariableItemList);
|
||||
variable_item_list_free(app->variable_item_list);
|
||||
app->variable_item_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,3 +10,4 @@ bool protopirate_ensure_text_input(ProtoPirateApp* app);
|
||||
bool protopirate_ensure_view_about(ProtoPirateApp* app);
|
||||
bool protopirate_ensure_receiver_view(ProtoPirateApp* app);
|
||||
void protopirate_views_free(ProtoPirateApp* app);
|
||||
void protopirate_variable_item_list_free(ProtoPirateApp* app);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ bool config_plugin_load(ProtoPirateApp* app) {
|
||||
}
|
||||
|
||||
const ProtoPirateConfigPlugin* plugin = plugin_manager_get_ep(manager, 0U);
|
||||
if(!plugin || !plugin->on_enter || !plugin->on_exit) {
|
||||
if(!plugin || !plugin->on_enter) {
|
||||
FURI_LOG_E(TAG, "Config plugin entry point is invalid");
|
||||
plugin_manager_free(manager);
|
||||
composite_api_resolver_free(resolver);
|
||||
|
||||
@@ -35,8 +35,11 @@ const char* const tx_power_text[TX_POWER_COUNT] = {
|
||||
|
||||
bool protopirate_ensure_variable_item_list(ProtoPirateApp* app) {
|
||||
furi_check(app);
|
||||
|
||||
if(app->variable_item_list) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, ProtoPirateViewVariableItemList);
|
||||
variable_item_list_free(app->variable_item_list);
|
||||
//Reassigned below... app->variable_item_list = NULL;
|
||||
}
|
||||
|
||||
app->variable_item_list = variable_item_list_alloc();
|
||||
@@ -470,22 +473,11 @@ static void plugin_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, ProtoPirateViewVariableItemList);
|
||||
}
|
||||
|
||||
static void plugin_on_exit(void* context) {
|
||||
ProtoPirateApp* app = context;
|
||||
|
||||
//Reset the variable item list.
|
||||
variable_item_list_set_selected_item(app->variable_item_list, 0);
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
variable_item_list_free(app->variable_item_list);
|
||||
//app->variable_item_list = NULL;
|
||||
}
|
||||
|
||||
static const ProtoPirateConfigPlugin protopirate_config_plugin = {
|
||||
.plugin_name = "ProtoPirate Config",
|
||||
.car_model_get_by_index = car_model_get_by_index,
|
||||
.car_model_get_count = car_model_get_count,
|
||||
.on_enter = plugin_on_enter,
|
||||
.on_exit = plugin_on_exit,
|
||||
};
|
||||
|
||||
static const FlipperAppPluginDescriptor protopirate_config_plugin_descriptor = {
|
||||
|
||||
@@ -31,5 +31,4 @@ typedef struct ProtoPirateConfigPlugin {
|
||||
SubGhzSetting* app_settings);
|
||||
uint16_t (*car_model_get_count)(void);
|
||||
void (*on_enter)(void* app);
|
||||
void (*on_exit)(void* app);
|
||||
} ProtoPirateConfigPlugin;
|
||||
|
||||
@@ -338,6 +338,9 @@ void protopirate_scene_receiver_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, ProtoPirateViewReceiver);
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, ProtoPirateCustomEventReceiverDeferredRxStart);
|
||||
|
||||
//Kill Config if it exists now to save memory.
|
||||
protopirate_variable_item_list_free(app);
|
||||
}
|
||||
|
||||
static void protopirate_scene_receiver_handle_back(ProtoPirateApp* app) {
|
||||
|
||||
@@ -30,8 +30,5 @@ bool protopirate_scene_receiver_config_on_event(void* context, SceneManagerEvent
|
||||
void protopirate_scene_receiver_config_on_exit(void* context) {
|
||||
ProtoPirateApp* app = context;
|
||||
|
||||
if(app->config_plugin && app->config_plugin->on_exit) {
|
||||
app->config_plugin->on_exit(app);
|
||||
}
|
||||
config_plugin_unload(app);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,9 @@ void protopirate_scene_start_on_enter(void* context) {
|
||||
app->submenu, scene_manager_get_scene_state(app->scene_manager, ProtoPirateSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, ProtoPirateViewSubmenu);
|
||||
|
||||
//Kill Config if it exists now to save memory.
|
||||
protopirate_variable_item_list_free(app);
|
||||
}
|
||||
|
||||
bool protopirate_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -87,6 +90,8 @@ bool protopirate_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, ProtoPirateSceneStart, event.event);
|
||||
FURI_LOG_I(TAG, "Suppressing Charging While in a scene.");
|
||||
if(event.event == SubmenuIndexProtoPirateAbout) {
|
||||
scene_manager_next_scene(app->scene_manager, ProtoPirateSceneAbout);
|
||||
consumed = true;
|
||||
@@ -112,7 +117,6 @@ bool protopirate_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
consumed = true;
|
||||
}
|
||||
#endif
|
||||
scene_manager_set_scene_state(app->scene_manager, ProtoPirateSceneStart, event.event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
|
||||
@@ -727,6 +727,13 @@ void protopirate_scene_timing_tuner_on_enter(void* context) {
|
||||
g_timing_ctx->is_receiving = true;
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, ProtoPirateViewAbout);
|
||||
|
||||
//Kill Config if it exists now to save memory.
|
||||
if(app->variable_item_list) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, ProtoPirateViewVariableItemList);
|
||||
variable_item_list_free(app->variable_item_list);
|
||||
app->variable_item_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool protopirate_scene_timing_tuner_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
Reference in New Issue
Block a user