diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 533068d420..a9be129e15 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -168,8 +168,13 @@ bool GERBVIEW_FRAME::LoadFileOrShowDialog( const wxString& aFileName, // Auto zoom / sort is only applied when no other files have been loaded if( isFirstFile ) { + int ly = GetActiveLayer(); + SortLayersByFileExtension(); Zoom_Automatique( false ); + + // Ensure the initial active graphic layer is updated after sorting. + SetActiveLayer( ly, true ); } return success; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index d241007d51..4f2a052e94 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -600,6 +600,12 @@ void GERBVIEW_FRAME::RemapLayers( const std::unordered_map<int, int>& remapping ReFillLayerWidget(); syncLayerBox( true ); + + // Reordering draw layers need updating the view items + GetCanvas()->GetView()->RecacheAllItems(); + GetCanvas()->GetView()->MarkDirty(); + GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL ); + GetCanvas()->Refresh(); }