fix crash occurs when switch between radio button to checkbox(#375)

This commit is contained in:
Jinhao 2019-01-04 21:58:48 +08:00
parent 345d65f6c9
commit e963c29646
2 changed files with 4 additions and 2 deletions

View File

@ -104,6 +104,7 @@ namespace drawerbase
struct element_tag struct element_tag
{ {
checkbox * uiobj; checkbox * uiobj;
event_handle eh_clicked;
event_handle eh_checked; event_handle eh_checked;
event_handle eh_destroy; event_handle eh_destroy;
event_handle eh_keyboard; event_handle eh_keyboard;

View File

@ -216,6 +216,7 @@ namespace nana{ namespace drawerbase
{ {
e.uiobj->radio(false); e.uiobj->radio(false);
e.uiobj->react(true); e.uiobj->react(true);
API::umake_event(e.eh_clicked);
API::umake_event(e.eh_checked); API::umake_event(e.eh_checked);
API::umake_event(e.eh_destroy); API::umake_event(e.eh_destroy);
API::umake_event(e.eh_keyboard); API::umake_event(e.eh_keyboard);
@ -232,7 +233,7 @@ namespace nana{ namespace drawerbase
el.uiobj = &uiobj; el.uiobj = &uiobj;
uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg) el.eh_checked = uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg)
{ {
if (arg.widget->checked()) if (arg.widget->checked())
{ {
@ -244,7 +245,7 @@ namespace nana{ namespace drawerbase
} }
}, true); }, true);
el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg) el.eh_clicked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
{ {
for (auto & i : ui_container_) for (auto & i : ui_container_)
i.uiobj->check(arg.window_handle == i.uiobj->handle()); i.uiobj->check(arg.window_handle == i.uiobj->handle());