[QGIS-trac] Re: [Quantum GIS] #2433: Fix relative paths from absolute-with-symlinks

Quantum GIS qgis at qgis.org
Fri Feb 12 05:30:19 EST 2010


#2433: Fix relative paths from absolute-with-symlinks
---------------------------------------------+------------------------------
        Reporter:  strk                      |         Owner:  nobody       
            Type:  patch                     |        Status:  new          
        Priority:  minor: annoyance          |     Milestone:  Version 1.5.0
       Component:  Project Loading / Saving  |       Version:  HEAD         
      Resolution:                            |      Keywords:               
Platform_version:                            |      Platform:  Debian       
        Must_fix:  No                        |   Status_info:  1            
---------------------------------------------+------------------------------
Comment (by strk):

 Replying to [comment:1 jef]:
 > What's the point in using two different paths to the same directory in
 one project?

 No point. It was qgis doing that, I just used the "browse" dialog to
 select
 the files, and maybe I started it from my home directory so had to go find
 the files somewhere. Didn't know I would have been somewhere else when re-
 opening
 the project and "saving as relative".

 > If you use the same path for both the datasources and the project, you
 already get what you want - whether or not the path includes a symlink.
 >
 > If different paths are used, it might be even to get exactly this
 behavior.

 I'm trying hard but I can't figure a reason why a user would ever want to
 get that
 behaviour. I would really expect it to "just work".

 Of course an *additional* "canonicalization" of paths could be performed
 at "load time"
 but you never know what the user want. He may have added a symlink for the
 precise reason
 to find a predictable *absolute* path in the project file for example...
 ... but, when you want to go "relative" you really want the relative path
 to be as small as possible and that's what you get if you canonicalize
 both paths
 in the project file and pathname of the project file itself. My patch only
 canonicalize
 the paths in the project file.

 > Moreover canonicalPath() only works on existing files and (some?) GRASS
 data sources have paths that only exist partly - and the patch would clear
 those.  This one wouldn't:
 >
 > {{{
 > Index: src/core/qgsproject.cpp
 > ===================================================================
 > --- src/core/qgsproject.cpp   (revision 12928)
 > +++ src/core/qgsproject.cpp   (working copy)
 > @@ -1409,6 +1409,9 @@
 >    }
 >
 >    QString srcPath = src;
 > +  QFileInfo fi( srcPath );
 > +  if ( fi.exists() )
 > +    srcPath = fi.canonicalFilePath();
 >    QString projPath = fileName();
 >
 >  #if defined( Q_OS_WIN )
 > }}}
 >
 > Still IMHO that patch is unnecessary and might even be counter
 productive.

 I would rather get a warning popup if a filename in the project file can't
 be found.
 After all you can't guarantee you'll produce a project file that will work
 if you
 can't find the files.

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/2433#comment:2>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list