From 85c3ae371519627746f420ee5b74e24fc2b48426 Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Mon, 2 Nov 2015 14:04:53 -0500 Subject: [PATCH] Common: fix subtle project path bug when loading sym-linked project files. * Assuming: a project exists in /a/b/project.pro, and /a/b is symlinked to /a/c 1. Load /a/b/project.pro 2. Load /a/c/project.pro Expectation: file name switches to /a/c/project.pro (even though they are the same file, a user would expect the path to reflect the file selection they just made) Reality: file name does not switch This is because PROJECT::SetProjectFullName() does not do anything if the path is not changed, and it uses wxFileName::SameAs() to check this. For some bizarre reason, wxFileName::SameAs compares filesystem inodes rather than actual paths. This patch instead creates a second wxFileName from the candidate name in order to normalize the path, and then compares paths directly. This should be much more in line with what a user would expect. --- common/project.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/project.cpp b/common/project.cpp index ebf8f13dac..a6b7546721 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -63,9 +63,13 @@ PROJECT::~PROJECT() void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) { + // Compare paths, rather than inodes, to be less surprising to the user. + // Create a temporary wxFileName to normalize the path + wxFileName candidate_path( aFullPathAndName ); + // Edge transitions only. This is what clears the project // data using the Clear() function. - if( m_project_name != aFullPathAndName ) + if( m_project_name.GetFullPath() != candidate_path.GetFullPath() ) { Clear(); // clear the data when the project changes.