I have a problem with reading qgs file by PyQGIS lib. I'm creating python standalone stript which externally use PyQGIS from installed QGIS desktop application. *The problem is that PyQGIS sometimes read qgs file but WITHOUT READING LAYERS INSIDE*. I'm using Ubuntu 18.04 LTS, django, python 3.6.9, QGIS 3.4.14-Madeira

PyQGIS helps me with reading and updating .qgs files. I'm always using same start and ending code.

|fromqgis.core importQgsProject,QgsApplicationapp =QgsApplication([],False)app.initQgis()app.exit()project =QgsProject.instance()project.read("/path/to/file.qgs")(PyQGISoperations)project.write()app.exit()|

And... the problem is that this code works fine... but never know how long, sometimes few days or few weeks but finally comes the moment when this code stops working properly. It still reads .qgs file but without layers inside, see groups but not layers. It should be impossible that code works fine for long time but some day it stops.

PyQGIS unfortunately works that way. The only thing comes to my mind is that the problem may be inside qgis desktop because PyQGIS is not common library. I belongs and works only with qgis desktop. This program maybe remember reading states or use multithreading with the way which i don't understand.

Of course, the problem may be completely different but i really don't have any more ideas how to change this code.

*Does anyone know how to fix it?*

Some logs from app which makes me wonder, maybe this will help.

|WARNING:QApplicationwas notcreated inthe main()thread.Loadinga file that was saved withan older version of qgis (saved in3.4.13-Madeira,loaded in3.4.14-Madeira).Problemsmay occur.QObject::~QObject:Timerscannot be stopped fromanother thread QObject::~QObject:Timerscannot be stopped fromanother thread QObject::connect:Cannotqueue arguments of type 'QDomDocument'(Makesure 'QDomDocument'isregistered using qRegisterMetaType().)|

_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to