From 63b5d8db43098b62107585fb330c050ba8774b2a Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 28 Feb 2021 14:30:16 -0500 Subject: [PATCH] Pcbnew: use MRU path when opening files in standalone mode Fixes https://gitlab.com/kicad/code/kicad/-/issues/7734 --- pcbnew/files.cpp | 9 +++++++-- pcbnew/tools/pcb_control.cpp | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 17fade4172..627cf2973c 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -73,7 +73,8 @@ * @param aKicadFilesOnly true to list KiCad pcb files plugins only, false to list import plugins. * @return true if chosen, else false if user aborted. */ -bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName, bool aKicadFilesOnly ) +bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileName, + bool aKicadFilesOnly ) { // This is a subset of all PLUGINs which are trusted to be able to // load a BOARD. User may occasionally use the wrong plugin to load a @@ -168,7 +169,10 @@ bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName, bo } else { - path = PATHS::GetDefaultUserProjectsPath(); + path = aParent->GetMruPath(); + + if( path.IsEmpty() ) + path = PATHS::GetDefaultUserProjectsPath(); // leave name empty } @@ -184,6 +188,7 @@ bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName, bo // Other cases are clear because of unique file extensions. *aCtl = aKicadFilesOnly ? 0 : KICTL_EAGLE_BRD; *aFileName = dlg.GetPath(); + aParent->SetMruPath( wxFileName( dlg.GetPath() ).GetPath() ); return true; } else diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 4e11166f4d..ada5cd4c76 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -56,8 +56,8 @@ using namespace std::placeholders; // files.cpp -extern bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName, - bool aKicadFilesOnly = false ); +extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileName, + bool aKicadFilesOnly = false ); extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );