From 9bd5af03f9dff370a34bbc919efd78a4f36a242f Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Mon, 6 Jan 2025 08:57:55 -0500 Subject: [PATCH] fix crash when selecting radar site with new ImGui contexts --- scwx-qt/source/scwx/qt/map/draw_layer.cpp | 6 +++++- scwx-qt/source/scwx/qt/map/draw_layer.hpp | 1 + scwx-qt/source/scwx/qt/map/radar_site_layer.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.cpp b/scwx-qt/source/scwx/qt/map/draw_layer.cpp index 4dc24f89..9588a160 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.cpp @@ -161,8 +161,12 @@ void DrawLayer::RenderWithoutImGui( p->textureAtlasBuildCount_ = newTextureAtlasBuildCount; } +void DrawLayer::ImGuiSelectContext() +{ + ImGui::SetCurrentContext(p->imGuiContext_); +} - void DrawLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) +void DrawLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) { StartImGuiFrame(); RenderWithoutImGui(params); diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.hpp b/scwx-qt/source/scwx/qt/map/draw_layer.hpp index 416c4e7f..a6fd685a 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.hpp @@ -37,6 +37,7 @@ protected: void ImGuiInitialize(); void RenderWithoutImGui(const QMapLibre::CustomLayerRenderParameters& params); + void ImGuiSelectContext(); private: std::unique_ptr p; diff --git a/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp index 431af597..7398ab36 100644 --- a/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_site_layer.cpp @@ -140,6 +140,7 @@ void RadarSiteLayer::Impl::RenderRadarSite( if (ImGui::Button(radarSite->id().c_str())) { Q_EMIT self_->RadarSiteSelected(radarSite->id()); + self_->ImGuiSelectContext(); } // Store hover text for mouse picking pass