From e45afdb912e85637f3db01a1977fff6736433ec9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 15 Sep 2018 22:35:32 +0100 Subject: [PATCH] Revert absolute-path asserts and fix off-by-one bug. Fixes: lp:1767582 * https://bugs.launchpad.net/kicad/+bug/1767582 --- common/project.cpp | 4 +--- common/single_top.cpp | 8 ++++---- eeschema/files-io.cpp | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/project.cpp b/common/project.cpp index 105e5096b4..7b93755b9f 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -78,9 +78,7 @@ void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) m_project_name = aFullPathAndName; - // There's no guarantee that this path is absolute. For instance, a relative - // path might have been passed via the command line. - // wxASSERT( m_project_name.IsAbsolute() ); + wxASSERT( m_project_name.IsAbsolute() ); wxASSERT( m_project_name.GetExt() == ProjectFileExtension ); diff --git a/common/single_top.cpp b/common/single_top.cpp index bff087f904..30e583892e 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -365,11 +365,11 @@ bool PGM_SINGLE_TOP::OnPgmInit() argSet.push_back( App().argv[i] ); } - // special attention to the first argument: argv[1] (==argSet[0]) - wxFileName argv1( argSet[0] ); - - if( argc - args_offset > 1 ) + // special attention to a single argument: argv[1] (==argSet[0]) + if( argc == args_offset + 1 ) { + wxFileName argv1( argSet[0] ); + #if defined(PGM_DATA_FILE_EXT) // PGM_DATA_FILE_EXT, if present, may be different for each compile, // it may come from CMake on the compiler command line, but often does not. diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 90e7f84e16..24ef300e64 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -201,6 +201,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in wxString fullFileName( aFileSet[0] ); + // We insist on caller sending us an absolute path, if it does not, we say it's a bug. + wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) ); + if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "Schematic file \"%s\" is already open." ),