Misc: fixes zealous MSVC static analyzer warnings + make GetInputSourceName(), GetMouseSourceName() a little more tolerant. (#8876)

This commit is contained in:
ocornut
2025-08-11 11:01:13 +02:00
parent 47c41483bd
commit 1c57dc21c2
3 changed files with 10 additions and 3 deletions

View File

@@ -10175,13 +10175,17 @@ void ImGui::SetNextFrameWantCaptureMouse(bool want_capture_mouse)
static const char* GetInputSourceName(ImGuiInputSource source)
{
const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad" };
IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT && source >= 0 && source < ImGuiInputSource_COUNT);
IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
if (source < 0 || source >= ImGuiInputSource_COUNT)
return "Unknown";
return input_source_names[source];
}
static const char* GetMouseSourceName(ImGuiMouseSource source)
{
const char* mouse_source_names[] = { "Mouse", "TouchScreen", "Pen" };
IM_ASSERT(IM_ARRAYSIZE(mouse_source_names) == ImGuiMouseSource_COUNT && source >= 0 && source < ImGuiMouseSource_COUNT);
IM_ASSERT(IM_ARRAYSIZE(mouse_source_names) == ImGuiMouseSource_COUNT);
if (source < 0 || source >= ImGuiMouseSource_COUNT)
return "Unknown";
return mouse_source_names[source];
}
static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
@@ -14157,6 +14161,7 @@ static void ImGui::NavUpdateWindowingApplyFocus(ImGuiWindow* apply_focus_window)
SetNavCursorVisibleAfterMove();
ClosePopupsOverWindow(apply_focus_window, false);
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
IM_ASSERT(g.NavWindow != NULL);
apply_focus_window = g.NavWindow;
if (apply_focus_window->NavLastIds[0] == 0)
NavInitWindow(apply_focus_window, false);