diff --git a/imgui_internal.h b/imgui_internal.h index e4e39820c8bb..961c2551577e 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -3225,7 +3225,16 @@ namespace ImGui IMGUI_API ImGuiIO& GetIOEx(ImGuiContext* ctx); IMGUI_API ImGuiPlatformIO& GetPlatformIOEx(ImGuiContext* ctx); inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; } - inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } + inline ImGuiWindow* GetCurrentWindow() + { + ImGuiContext& g = *GImGui; + #ifdef IMGUI_BUNDLE_PYTHON_API + // Help python users, because otherwise, this leads to an un-debuggable segfault + IM_ASSERT(g.CurrentWindow != NULL && "ImGui::GetCurrentWindow() -> CurrentWindow is NULL. This is likely because you are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame()."); + #endif + g.CurrentWindow->WriteAccessed = true; + return g.CurrentWindow; + } IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id); IMGUI_API ImGuiWindow* FindWindowByName(const char* name); IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);