Bug report #15656

Loading QLR file with relative path does not work correctly

Added by Dominique Lyszczarz about 8 years ago. Updated about 7 years ago.

Status:Closed
Priority:Normal
Assignee:René-Luc ReLuc
Category:Project Loading/Saving
Affected QGIS version:2.18.14 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:23579

Description

Hi,

I have some troubles loading QLR files with relative path. The path in the QLR is relative to the folder where the QLR file was saved which is good but it seems QGIS considers the path relative to the folder where the QGS project is saved.

For examle when I try to load a QLR in:
- a new, blank and non saved project > it works
- a QGS project saved in the same folder than the QLR file > it works
- a QGS project saved in a different folder than the QLR file > it does not works

Associated revisions

Revision 533a8f8a
Added by René-Luc ReLuc about 7 years ago

[PATCH] [BUGFIX] Load layer from definition does not use qlr as relative path

Fixes #15656 Loading QLR file with relative path does not work correctly

Revision ba71e79f
Added by René-Luc ReLuc almost 7 years ago

[BUGFIX] Load layer from definition does not use qlr as relative path

Fixes #15656 Loading QLR file with relative path does not work correctly

History

#1 Updated by Tudor Bărăscu about 8 years ago

See http://docs.qgis.org/2.14/en/docs/user_manual/introduction/qgis_configuration.html#project-properties

You can choose between relative and absolute paths.

As you observed, QGIS considers the relative paths to the qgs project.
IMHO qlr is a definition of a layer to be used in the project. So, the datasource should be relative to the project and NOT to the qlr (which just defines the path to the datasource from the project perspective).

Are you saying that you're loading in a project a qlr file and it works but after saving the project (without loading the qlr file afterwards) it doesn't work anymore?

#2 Updated by Dominique Lyszczarz about 8 years ago

Actually when saving a QLR the datasource path is relative to QLR destination folder, not the QGS one.

It seems this behaviour was fixed in #10858

But on another hand when QGIS load a QLR it search the datasource with a path relative to the folder where the qgs is saved.

This inconsistency causes lot of troubles.

For example if I have a shapefile in the folder foo/data and a qgs project in the folder foo/qgs, load the shp and save a new QLR to foo/myqlr.qlr then just trying to reopen this QLR and it does not find the datasource (there is no error message but the layer entry in the TOC is empty)

The path in the QLR is ./data/shapefile.shp which is correct (== foo/data/shapefile.shp) but I suspect QGIS search the source at foo/qgs/data/shapefile.shp. If I just resave my project to /foo/myproject.qgs or if I change the path in the QLR to ../data/shapefile.shp, then I can load correctly my QLR file.

#3 Updated by Juan Manuel Perez almost 8 years ago

I agree with Dominique. We hava also stumbled into some problems caused by that inconsistency he points out:
"When saving a QLR the datasource path is relative to QLR destination folder, not the QGS one. But, on another hand, when QGIS load a QLR it searchs the datasource with a path relative to the folder where the QGS is saved"
If this behaviour is to remain as it is now, then maybe it could be fair if we could have a warning telling the user that loading the generated QLR will fail unless moved next to the QGS file.

#4 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No
  • Regression? set to No

#5 Updated by Giovanni Manghi about 7 years ago

  • Category set to Project Loading/Saving
  • Description updated (diff)

#6 Updated by Dominique Lyszczarz about 7 years ago

  • Status changed from Open to Closed

Tested on latest master, now it works correctly. Seems it was fixed a few months ago in 5f5c1ddb15c214a8a920ca6b34fab85dfab4f0a6

Thanks !

#7 Updated by René-Luc ReLuc about 7 years ago

  • Status changed from Closed to Reopened
  • Assignee set to René-Luc ReLuc
  • Affected QGIS version changed from 2.16.2 to 2.18.14

This issue has been fixed in master but not in LTR.

#8 Updated by René-Luc ReLuc about 7 years ago

  • Pull Request or Patch supplied changed from No to Yes

#9 Updated by René-Luc ReLuc about 7 years ago

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

Also available in: Atom PDF