From 874be359e06e1a9c973351de6b6afcb3506836a9 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 6 Feb 2024 21:32:55 -0500 Subject: [PATCH] Use a more specific path for instance checker --- common/paths.cpp | 12 +++++++++++- common/pgm_base.cpp | 6 +++++- include/paths.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/common/paths.cpp b/common/paths.cpp index 3a1b6e42ae..dc73d5c1c3 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -385,6 +385,16 @@ wxString PATHS::GetDocumentationPath() } +wxString PATHS::GetInstanceCheckerPath() +{ + wxFileName path; + path.AssignDir( wxStandardPaths::Get().GetTempDir() ); + path.AppendDir( "kicad" ); + path.AppendDir( "instances" ); + return path.GetPathWithSep(); +} + + bool PATHS::EnsurePathExists( const wxString& aPath ) { wxFileName path( aPath ); @@ -576,4 +586,4 @@ const wxString& PATHS::GetExecutablePath() } return exe_path; -} \ No newline at end of file +} diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 25980ca30c..164994e570 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -489,8 +489,12 @@ bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit, bool aIsUnitTest ) return false; } #endif + + wxString instanceCheckerDir = PATHS::GetInstanceCheckerPath(); + PATHS::EnsurePathExists( instanceCheckerDir ); + m_pgm_checker = std::make_unique(); - m_pgm_checker->Create( pgm_name, wxStandardPaths::Get().GetTempDir() ); + m_pgm_checker->Create( pgm_name, instanceCheckerDir ); // Init KiCad environment // the environment variable KICAD (if exists) gives the kicad path: diff --git a/include/paths.h b/include/paths.h index f099eeda33..05d12707b1 100644 --- a/include/paths.h +++ b/include/paths.h @@ -148,6 +148,11 @@ public: */ static wxString GetDocumentationPath(); + /** + * Gets the path used for wxSingleInstanceChecker lock files + */ + static wxString GetInstanceCheckerPath(); + /** * Attempts to create a given path if it does not exist */