Skip to content

Commit

Permalink
Alternative fix for bug introduced in d845135 (#1651), fix CTRL+Tab a…
Browse files Browse the repository at this point in the history
…nd fallback tooltip.
  • Loading branch information
ocornut committed Jan 2, 2019
1 parent 3e30bfd commit b3469fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 9 additions & 5 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3349,6 +3349,7 @@ void ImGui::NewFrame()
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
Begin("Debug##Default");
g.FrameScopePushedImplicitWindow = true;

#ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PostNewFrame();
Expand Down Expand Up @@ -3580,9 +3581,6 @@ void ImGui::EndFrame()
return;
IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");

g.FrameScopeActive = false;
g.FrameCountEnded = g.FrameCount;

// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)
{
Expand All @@ -3607,11 +3605,12 @@ void ImGui::EndFrame()
}

// Hide implicit/fallback "Debug" window if it hasn't been used
g.FrameScopePushedImplicitWindow = false;
if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
g.CurrentWindow->Active = false;
End();

// Show CTRL+TAB list
// Show CTRL+TAB list window
if (g.NavWindowingTarget)
NavUpdateWindowingList();

Expand All @@ -3632,6 +3631,10 @@ void ImGui::EndFrame()
g.DragDropWithinSourceOrTarget = false;
}

// End frame
g.FrameScopeActive = false;
g.FrameCountEnded = g.FrameCount;

// Initiate moving window
if (g.ActiveId == 0 && g.HoveredId == 0)
{
Expand Down Expand Up @@ -5283,11 +5286,12 @@ void ImGui::End()
{
ImGuiContext& g = *GImGui;

if (g.CurrentWindowStack.Size <= 1 && g.FrameScopeActive)
if (g.CurrentWindowStack.Size <= 1 && g.FrameScopePushedImplicitWindow)
{
IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
return; // FIXME-ERRORHANDLING
}
IM_ASSERT(g.CurrentWindowStack.Size > 0);

ImGuiWindow* window = g.CurrentWindow;

Expand Down
5 changes: 3 additions & 2 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ struct ImGuiTabBarSortItem
struct ImGuiContext
{
bool Initialized;
bool FrameScopeActive; // Set by NewFrame(), cleared by EndFrame()/Render()
bool FrameScopeActive; // Set by NewFrame(), cleared by EndFrame()
bool FrameScopePushedImplicitWindow; // Set by NewFrame(), cleared by EndFrame()
bool FontAtlasOwnedByContext; // Io.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
ImGuiIO IO;
ImGuiStyle Style;
Expand Down Expand Up @@ -859,7 +860,7 @@ struct ImGuiContext
ImGuiContext(ImFontAtlas* shared_font_atlas) : OverlayDrawList(NULL)
{
Initialized = false;
FrameScopeActive = false;
FrameScopeActive = FrameScopePushedImplicitWindow = false;
Font = NULL;
FontSize = FontBaseSize = 0.0f;
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
Expand Down

0 comments on commit b3469fa

Please sign in to comment.