mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2025-10-30 08:03:03 +00:00
Close context when showing or hiding a context and reopen afterwards to prevent deadlocks
This commit is contained in:
parent
2e8bd48747
commit
ebd11b2d84
1 changed files with 17 additions and 5 deletions
|
|
@ -796,17 +796,29 @@ void recompui::message_box(const char* msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void recompui::show_context(ContextId context, std::string_view param) {
|
void recompui::show_context(ContextId context, std::string_view param) {
|
||||||
|
ContextId prev_context = recompui::try_close_current_context();
|
||||||
|
{
|
||||||
std::lock_guard lock{ ui_state_mutex };
|
std::lock_guard lock{ ui_state_mutex };
|
||||||
|
|
||||||
// TODO call the context's on_show callback with the param.
|
// TODO call the context's on_show callback with the param.
|
||||||
ui_state->show_context(context);
|
ui_state->show_context(context);
|
||||||
}
|
}
|
||||||
|
if (prev_context != ContextId::null()) {
|
||||||
|
prev_context.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void recompui::hide_context(ContextId context) {
|
void recompui::hide_context(ContextId context) {
|
||||||
|
ContextId prev_context = recompui::try_close_current_context();
|
||||||
|
{
|
||||||
std::lock_guard lock{ ui_state_mutex };
|
std::lock_guard lock{ ui_state_mutex };
|
||||||
|
|
||||||
ui_state->hide_context(context);
|
ui_state->hide_context(context);
|
||||||
}
|
}
|
||||||
|
if (prev_context != ContextId::null()) {
|
||||||
|
prev_context.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void recompui::hide_all_contexts() {
|
void recompui::hide_all_contexts() {
|
||||||
std::lock_guard lock{ui_state_mutex};
|
std::lock_guard lock{ui_state_mutex};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue