mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	Error recovery: Extraneous/undesired calls to End() are now being caught by an assert in the End() function itself at the call site (instead of being reported in EndFrame). Past the assert, they don't lead to crashes any more. Missing calls to End(), pass the assert, should not lead to crashes any more, nor to the fallback/debug window appearing on screen. (#1651).
This commit is contained in:
		
							
								
								
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -3555,6 +3555,9 @@ 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) | ||||
|     { | ||||
| @@ -3567,9 +3570,15 @@ void ImGui::EndFrame() | ||||
|     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?"); | ||||
|             while (g.CurrentWindowStack.Size > 1) // FIXME-ERRORHANDLING | ||||
|                 End(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // Hide implicit/fallback "Debug" window if it hasn't been used | ||||
| @@ -3665,9 +3674,6 @@ void ImGui::EndFrame() | ||||
|     g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; | ||||
|     memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters)); | ||||
|     memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); | ||||
|  | ||||
|     g.FrameScopeActive = false; | ||||
|     g.FrameCountEnded = g.FrameCount; | ||||
| } | ||||
|  | ||||
| void ImGui::Render() | ||||
| @@ -5251,6 +5257,13 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, | ||||
| void ImGui::End() | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|  | ||||
|     if (g.CurrentWindowStack.Size <= 1 && g.FrameScopeActive) | ||||
|     { | ||||
|         IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!"); | ||||
|         return; // FIXME-ERRORHANDLING | ||||
|     } | ||||
|  | ||||
|     ImGuiWindow* window = g.CurrentWindow; | ||||
|  | ||||
|     if (window->DC.ColumnsSet != NULL) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user