Bug report #16242

QGIS 2.18.4 saves always with absolute paths

Added by Giovanni Manghi over 2 years ago. Updated over 1 year ago.

Status:Closed
Priority:High
Assignee:Alessandro Pasotti
Category:Project Loading/Saving
Affected QGIS version:2.18.4 Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:24152

Description

Regardless of what chosen in project properties.

Master seems ok.


Related issues

Duplicated by QGIS Application - Bug report #16550: Virtual layer path is not relative Closed 2017-05-15

Associated revisions

Revision 913527b4
Added by Alessandro Pasotti over 2 years ago

[bugfix] Fixes #16242 saves always with absolute paths

History

#1 Updated by Giovanni Manghi over 2 years ago

  • Affected QGIS version changed from 2.18.3 to 2.18.4

#2 Updated by Richard Duivenvoorde over 2 years ago

Hi, I just created a fresh project with current 2.18.4 yesterday, and sent it to a client with the shape files next to it, (and was afraid that I hit this bug...).

So I just checked the .qgs file, but I see: <datasource>./mylayer.shp</datasource> in the xml.

It was a fresh project, and I have default 'relative paths'...

I have a yesterday fresh compiled 2.18.4, which in the checkbox says:
QGIS code revision 2ccdac770b

So is there a certain thing you did? To have this?

#3 Updated by Giovanni Manghi over 2 years ago

Richard Duivenvoorde wrote:

Hi, I just created a fresh project with current 2.18.4 yesterday, and sent it to a client with the shape files next to it, (and was afraid that I hit this bug...).

So I just checked the .qgs file, but I see: <datasource>./mylayer.shp</datasource> in the xml.

It was a fresh project, and I have default 'relative paths'...

I have a yesterday fresh compiled 2.18.4, which in the checkbox says:
QGIS code revision 2ccdac770b

So is there a certain thing you did? To have this?

Hi Richard,
yesterday when I first checked and replied in the dev ML I wasn't able to replicate.

The tested again and again in Windows with both 2.18.4 and master and with first I regularly only got absolute paths regardless the project configs. This was never the case on master.

#4 Updated by Christian S over 2 years ago

We too have problems with relative paths becoming absolute paths.

Some background:
Several people access a QGIS-project with relative paths for some datasources.
All of them use linux (Ubuntu 14.04 and 16.04) but use different methods of mounting the project directory from a samba share so the basepath is different on each computer.
Some use the gvfs mechanism from Ubuntu and others use mount with autofs. The used QGIS-Versions are 2.18.4 and 2.18.5.

We observe that sometimes relative paths become absolute paths in this scenario but unfortunately we have not found a reproducable test case yet.
This [1] Question with answer may be related, too. The solution offered there seems to work for our broken QGIS-projects.

[1]: http://gis.stackexchange.com/questions/210992/relative-path-not-working-in-qgis

#5 Updated by Alexander Bruy over 2 years ago

  • Status changed from Open to Feedback

Seems works fine in 2.18.6

#6 Updated by Giovanni Manghi over 2 years ago

Alexander Bruy wrote:

Seems works fine in 2.18.6

Alex this is tricky, not easy to replicate. I have seen this lately too, also on 2.18.5, possibly .6.

Try open a project with a few file based layers, and check the .qgs file if it has absolute paths.

#7 Updated by Paul Henshaw over 2 years ago

Hi all,

I am able to reproduce the problem using the "Save As" feature, as described in https://gis.stackexchange.com/questions/210992/relative-path-not-working-in-qgis

_It seems that the the relative path for a shp file will be changed to an absolute path after the project file is "saved as" a new project file. (see images below).

[...]

After saving the current QGIS project file as a new file, you MUST press the SAVE button so as to confirm that the relative path is registered in the project file. Otherwise, the absolute path will be used._

I am currently using QGIS 2.18.7 (64bit Windows 10) but was also able to reproduce using 2.18.3.

#8 Updated by Giovanni Manghi over 2 years ago

  • Status changed from Feedback to Open

#9 Updated by Paul Henshaw over 2 years ago

Paul Henshaw wrote:

I am currently using QGIS 2.18.7 (64bit Windows 10) but was also able to reproduce using 2.18.3.

My colleague confirms that the behaviour is the same using 2.18.7 on Ubuntu 16.04 LTS (64bit).

#10 Updated by Giovanni Manghi over 2 years ago

  • Regression? set to Yes

#11 Updated by Giovanni Manghi over 2 years ago

  • Priority changed from Severe/Regression to High

#12 Updated by Giovanni Manghi over 2 years ago

  • Easy fix? set to No

#13 Updated by Alessandro Pasotti over 2 years ago

  • Description updated (diff)
  • Assignee set to Alessandro Pasotti

#14 Updated by Anonymous over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#15 Updated by Giovanni Manghi over 2 years ago

  • Resolution set to fixed/implemented

#16 Updated by Alessandro Pasotti over 2 years ago

  • Resolution deleted (fixed/implemented)

Explanation: when saving the project with a new name and the destination file did not exist, the path of the destintion file was blank, breaking the algorithm that build the relative path.
For this reason the bug could not be reproduced when saving (overwriting) an existing project file.

#17 Updated by Alessandro Pasotti over 2 years ago

  • Resolution set to fixed/implemented

#18 Updated by Jürgen Fischer over 2 years ago

#19 Updated by Patrick Dunford about 2 years ago

This issue can be produced in master revision 313ec55640adf3696d8b7554cc6d9b7fc319c2df

Do I assume if I pull the zip file from https://github.com/qgis/QGIS/tree/913527b4c95dce5f0bc3c6def52c29f6341cec39 that I will get the fix to this problem.

#20 Updated by Alessandro Pasotti about 2 years ago

yes

#21 Updated by Patrick Dunford about 2 years ago

That one is 2.18, I need the version of master that has that fix incorporated.

#22 Updated by Giovanni Manghi about 2 years ago

Patrick Dunford wrote:

This issue can be produced in master revision 313ec55640adf3696d8b7554cc6d9b7fc319c2df

if is not fixed in master then a new (regression) ticket must be opened. Thanks.

#23 Updated by Patrick Dunford over 1 year ago

See also #17824

Also available in: Atom PDF