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.
This commit is contained in:
parent
0a9a07af2e
commit
85c3ae3715
|
@ -63,9 +63,13 @@ PROJECT::~PROJECT()
|
||||||
|
|
||||||
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
|
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
|
// Edge transitions only. This is what clears the project
|
||||||
// data using the Clear() function.
|
// 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.
|
Clear(); // clear the data when the project changes.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue