mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-03 17:24:24 +00:00 
			
		
		
		
	Fixed crash when appending with BeginMainMenuBar() more than once and no other window are showing. (#2567) + comments
This commit is contained in:
		@@ -46,6 +46,7 @@ Other Changes:
 | 
			
		||||
  It wasn't much of a problem because we typically use the return value instead of IsItemEdited() here.
 | 
			
		||||
- Fixed uses of IsItemDeactivated(), IsItemDeactivatedAfterEdit() on multi-components widgets and
 | 
			
		||||
  after EndGroup(). (#2550, #1875)
 | 
			
		||||
- Fixed crash when appending with BeginMainMenuBar() more than once and no other window are showing. (#2567)
 | 
			
		||||
- Scrollbar: Very minor bounding box adjustment to cope with various border size.
 | 
			
		||||
- ImFontAtlas: FreeType: Added RasterizerFlags::Monochrome flag to disable font anti-aliasing. (#2545)
 | 
			
		||||
  Combine with RasterizerFlags::MonoHinting for best results.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -2831,9 +2831,13 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
 | 
			
		||||
    {
 | 
			
		||||
        // Navigation processing runs prior to clipping early-out
 | 
			
		||||
        //  (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
 | 
			
		||||
        //  (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window.
 | 
			
		||||
        //      it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
 | 
			
		||||
        //      We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
 | 
			
		||||
        //  (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests 
 | 
			
		||||
        //      unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of 
 | 
			
		||||
        //      thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
 | 
			
		||||
        //      We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able
 | 
			
		||||
        //      to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
 | 
			
		||||
        // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
 | 
			
		||||
        // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
 | 
			
		||||
        window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
 | 
			
		||||
        if (g.NavId == id || g.NavAnyRequest)
 | 
			
		||||
            if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
 | 
			
		||||
 
 | 
			
		||||
@@ -5850,7 +5850,7 @@ void ImGui::EndMainMenuBar()
 | 
			
		||||
    // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
 | 
			
		||||
    // FIXME: With this strategy we won't be able to restore a NULL focus.
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0)
 | 
			
		||||
    if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0 && !g.NavAnyRequest)
 | 
			
		||||
        FocusTopMostWindowUnderOne(g.NavWindow, NULL);
 | 
			
		||||
 | 
			
		||||
    End();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user