mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Internals: Routing recoverable user errors via IMGUI_USER_ERROR() macro. (#1651)
This commit is contained in:
parent
25eee91542
commit
03852470de
11
imgui.cpp
11
imgui.cpp
@ -5820,17 +5820,16 @@ void ImGui::End()
|
|||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
|
||||||
// Error checking: verify that user hasn't called End() too many times!
|
// Error checking: verify that user hasn't called End() too many times!
|
||||||
// FIXME-ERRORHANDLING
|
|
||||||
if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow)
|
if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow)
|
||||||
{
|
{
|
||||||
IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
|
IMGUI_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IM_ASSERT(g.CurrentWindowStack.Size > 0);
|
IM_ASSERT(g.CurrentWindowStack.Size > 0);
|
||||||
|
|
||||||
// Error checking: verify that user doesn't directly call End() on a child window.
|
// Error checking: verify that user doesn't directly call End() on a child window.
|
||||||
if (window->Flags & ImGuiWindowFlags_ChildWindow)
|
if (window->Flags & ImGuiWindowFlags_ChildWindow)
|
||||||
IM_ASSERT(g.WithinEndChild && "Must call EndChild() and not End()!");
|
IMGUI_USER_ERROR(g.WithinEndChild, "Must call EndChild() and not End()!");
|
||||||
|
|
||||||
// Close anything that is open
|
// Close anything that is open
|
||||||
if (window->DC.CurrentColumns)
|
if (window->DC.CurrentColumns)
|
||||||
@ -7004,13 +7003,13 @@ static void ImGui::ErrorCheckEndFrame()
|
|||||||
{
|
{
|
||||||
if (g.CurrentWindowStack.Size > 1)
|
if (g.CurrentWindowStack.Size > 1)
|
||||||
{
|
{
|
||||||
IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
|
IMGUI_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
|
||||||
while (g.CurrentWindowStack.Size > 1) // FIXME-ERRORHANDLING
|
while (g.CurrentWindowStack.Size > 1)
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
|
IMGUI_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,11 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
|||||||
#define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
|
#define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
|
||||||
#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
|
#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
|
||||||
|
|
||||||
|
// Error handling
|
||||||
|
#ifndef IMGUI_USER_ERROR
|
||||||
|
#define IMGUI_USER_ERROR(_EXPR, _MSG) IM_ASSERT((_EXPR) && (_MSG)) // Recoverable User Error
|
||||||
|
#endif
|
||||||
|
|
||||||
// Debug Logging
|
// Debug Logging
|
||||||
#ifndef IMGUI_DEBUG_LOG
|
#ifndef IMGUI_DEBUG_LOG
|
||||||
#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
|
#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
|
||||||
|
@ -6472,8 +6472,8 @@ void ImGui::EndTabBar()
|
|||||||
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
||||||
if (tab_bar == NULL)
|
if (tab_bar == NULL)
|
||||||
{
|
{
|
||||||
IM_ASSERT(tab_bar != NULL && "Mismatched BeginTabBar()/EndTabBar()!");
|
IMGUI_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!");
|
||||||
return; // FIXME-ERRORHANDLING
|
return;
|
||||||
}
|
}
|
||||||
if (tab_bar->WantLayout)
|
if (tab_bar->WantLayout)
|
||||||
TabBarLayout(tab_bar);
|
TabBarLayout(tab_bar);
|
||||||
@ -6869,8 +6869,8 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
|
|||||||
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
||||||
if (tab_bar == NULL)
|
if (tab_bar == NULL)
|
||||||
{
|
{
|
||||||
IM_ASSERT(tab_bar && "Needs to be called between BeginTabBar() and EndTabBar()!");
|
IMGUI_USER_ERROR(tab_bar, "BeginTabItem() Needs to be called between BeginTabBar() and EndTabBar()!");
|
||||||
return false; // FIXME-ERRORHANDLING
|
return false;
|
||||||
}
|
}
|
||||||
bool ret = TabItemEx(tab_bar, label, p_open, flags);
|
bool ret = TabItemEx(tab_bar, label, p_open, flags);
|
||||||
if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
|
if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
|
||||||
|
Loading…
Reference in New Issue
Block a user