RenderWidget: Fix random crash due to missing ImGui context

`ImGui::GetIO` performs an assertion that a context exists, and if one doesn't then things will likely crash.  Unfortunately this crash is hard to consistently reproduce.
This commit is contained in:
Pokechu22 2022-02-16 12:00:37 -08:00 committed by Admiral H. Curtiss
parent c931529e7a
commit e37aa3ed90
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
1 changed files with 3 additions and 0 deletions

View File

@ -554,6 +554,9 @@ void RenderWidget::SetImGuiKeyMap()
}}; }};
auto lock = g_renderer->GetImGuiLock(); auto lock = g_renderer->GetImGuiLock();
if (!ImGui::GetCurrentContext())
return;
for (auto [imgui_key, qt_key] : key_map) for (auto [imgui_key, qt_key] : key_map)
ImGui::GetIO().KeyMap[imgui_key] = (qt_key & 0x1FF); ImGui::GetIO().KeyMap[imgui_key] = (qt_key & 0x1FF);
} }