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 Sep 10, 2024
1 parent 75743b5 commit d1ce9c2
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 @@ -3391,7 +3391,16 @@ namespace ImGui
// - ImGui::NewFrame() has never been called, which is illegal.
// - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
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 d1ce9c2

Please sign in to comment.