Layer data source changing spontaneously

I have a project in QGIS 3.22 configured as a stand alone project in QField.

I have manually changed the data source of several layers (shp files).

I have saved the project, closed it and opened it again and the data source changes have been saved. However, intermittently when working on the project, the layer data source is now changing without my (user) intervention.

I have multiple QField Projects with exactly the same layer structure. It seems the layers spontaneously change to either (1) the last opened project, or (2) the location of the template on which the project was originally based.

Has anyone else come across this issue and knows what may be causing it to happen?

Thanks


Imported from GitHub discussion by @Oisin-JK on 2022-10-04T09:57:57Z

Uploading these problematic projects will increase the chances a developer to pick them and to replicate the issue. Having exact reproduction steps described would be neccessary too.


Imported from GitHub comment by @suricactus on 2022-10-08T22:14:23Z

Unfortunately the error occurs unpredictably, so I cannot provide steps to replicate it. The next time it happens, I will upload an example project.


Imported from GitHub comment by @Oisin-JK on 2022-10-09T17:32:07Z

You mentioned you have multiple projects with manually edited data source. I believe the layer ids are the same, which might cause falty behaviour (more likely on QGIS side, but QField also might be to blame). I am pretty sure if you play with these two projects you will be able to reproduce it. If you manage, it is worth trying to follow the same steps in QGIS too.

Anyway, a workaround would be to change the layer ids to be unique across all projects.


Imported from GitHub comment by @suricactus on 2022-10-10T08:19:36Z

Thanks for the insight. I’ll try to reproduce. I manually change the data source of a layer only occasionally. But my layers are identical because they are created froma template. Renaming layers for each new project is not really viable (unless I get round to learning some python).


Imported from GitHub comment by @Oisin-JK on 2022-10-10T08:35:40Z