Opened 16 years ago

Last modified 15 years ago

#50 assigned defect

Reconsider implementation of QString QDir::canonicalPath()

Reported by: rudi Owned by: dmik
Priority: normal Milestone:
Component: 3rdparty Version:
Severity: normal Keywords:
Cc:

Description

The current implementation temporary changes the current directory. This can lead to problems in a multithreaded environment. Suggested workaround:

QString QDir::canonicalPath() const
{
  QString r;
  char tmp[PATH_MAX];

  if( DosQueryPathInfo( QFile::encodeName( dPath ),
                    FIL_QUERYFULLNAME, tmp, sizeof(tmp) ) == 0 )
    r = QFile::decodeName( tmp );
  else
    r = dPath;

  slashify( r );
  return r;
}

Change History (1)

comment:1 Changed 15 years ago by dmik

Status: newassigned

rudi, your true. I've applied your fix in r187 with two modifications:

  1. We use realpath() when it's kLIBC (to make sure pseudo-symlinks implemented through EAs there are properly resolved) and your code otherwise.
  2. We return a null string if something fails (instead of just dPath itself) because this is how it works on other platforms.

Please check that it still works in your case.

P.S. Note that trac->maillist notification is broken ATM, so you may not notice any progress here...

P.P.S. Thank you a lot for contributing to the project and big sorry that I couldn't react to all your tickets instantly (no time + low interest to the project these days). Please contact me by email if you still want to actively participate (so that we could discuss the details).

Note: See TracTickets for help on using tickets.