Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Crash of App Info Context Menu #488

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/app/ui/launcher/apps.controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void action_cb_pair(apps_fragment_t *controller, lv_obj_t *buttons, uint1

static void update_grid_config(apps_fragment_t *controller);

static void open_context_menu(apps_fragment_t *fragment, const apploader_item_t *app);
static void open_context_menu(apps_fragment_t *fragment, appitem_viewholder_t *holder);

static void context_menu_cancel_cb(lv_event_t *event);

Expand Down Expand Up @@ -548,9 +548,7 @@ static void item_click_cb(lv_event_t *event) {
int current_app = pcmanager_server_current_app(pcmanager, &controller->uuid);
if (current_app != 0) {
if (holder->app_id == current_app) {
const apploader_item_t *item = apploader_list_item_by_id(controller->apploader_apps, holder->app_id);
assert(item != NULL);
open_context_menu(controller, item);
open_context_menu(controller, holder);
}
return;
}
Expand All @@ -567,10 +565,7 @@ static void item_longpress_cb(lv_event_t *event) {
return;
}
lv_event_send(target, LV_EVENT_RELEASED, lv_event_get_indev(event));
appitem_viewholder_t *holder = (appitem_viewholder_t *) lv_obj_get_user_data(target);
const apploader_item_t *item = apploader_list_item_by_id(controller->apploader_apps, holder->app_id);
assert(item != NULL);
open_context_menu(controller, item);
open_context_menu(controller, (appitem_viewholder_t *) lv_obj_get_user_data(target));
}

static void launcher_launch_game(apps_fragment_t *controller, const apploader_item_t *app) {
Expand Down Expand Up @@ -696,9 +691,11 @@ static void action_cb_pair(apps_fragment_t *controller, lv_obj_t *buttons, uint1
pair_dialog_open(&controller->uuid);
}

static void open_context_menu(apps_fragment_t *fragment, const apploader_item_t *app) {
static void open_context_menu(apps_fragment_t *fragment, appitem_viewholder_t *holder) {
const apploader_item_t *app = apploader_list_item_by_id(fragment->apploader_apps, holder->app_id);
assert(app != NULL);
lv_obj_t *msgbox = lv_msgbox_create(NULL, app->base.name, NULL, NULL, false);
lv_obj_set_user_data(msgbox, (void *) app);
lv_obj_set_user_data(msgbox, (void *) holder);
lv_obj_t *content = lv_msgbox_get_content(msgbox);
lv_obj_add_flag(content, LV_OBJ_FLAG_EVENT_BUBBLE);
lv_obj_set_flex_flow(content, LV_FLEX_FLOW_COLUMN);
Expand Down Expand Up @@ -748,17 +745,20 @@ static void context_menu_click_cb(lv_event_t *e) {
lv_obj_t *current_target = lv_event_get_current_target(e);
if (target->parent != current_target) { return; }
lv_obj_t *mbox = lv_event_get_current_target(e)->parent;
apps_fragment_t *controller = lv_event_get_user_data(e);
apps_fragment_t *self = lv_event_get_user_data(e);
appitem_viewholder_t *holder = lv_obj_get_user_data(mbox);
const apploader_item_t *app = apploader_list_item_by_id(self->apploader_apps, holder->app_id);
assert(app != NULL);
if (lv_obj_get_user_data(target) == launcher_quit_game) {
launcher_quit_game(controller);
launcher_quit_game(self);
} else if (lv_obj_get_user_data(target) == launcher_launch_game) {
launcher_launch_game(controller, lv_obj_get_user_data(mbox));
launcher_launch_game(self, app);
} else if (lv_obj_get_user_data(target) == launcher_toggle_fav) {
launcher_toggle_fav(controller, lv_obj_get_user_data(mbox));
launcher_toggle_fav(self, app);
} else if (lv_obj_get_user_data(target) == launcher_toggle_hidden) {
launcher_toggle_hidden(controller, lv_obj_get_user_data(mbox));
launcher_toggle_hidden(self, app);
} else if (lv_obj_get_user_data(target) == app_detail_dialog) {
app_detail_dialog(controller, lv_obj_get_user_data(mbox));
app_detail_dialog(self, app);
}
lv_msgbox_close_async(mbox);
}
Expand Down
Loading