Skip to content

Commit

Permalink
[Bundle]: GetCurrentWindow / add assert for python: Help python users…
Browse files Browse the repository at this point in the history
… against un-debuggable segfault
  • Loading branch information
pthom committed Dec 22, 2024
1 parent 71caaee commit ec3b2b8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ec3b2b8

Please sign in to comment.