I'm having trouble with QGIS (2.18.12) project files on Windows, if saved via Python command. The project file is saved via:
project = QgsProject.instance()
project.write()
The file is saved, I can open it and it contains all the layers it should.
However if I first use the save command (described above) and then press the QGIS 'Save button' (the disk symbol) I get an message saying:
Project file was changed
... (see image)
This confuses me as I'm in fact overwriting the existing project file. If I reopen the file it will show me the newly saved status.
Besides this the actual message doesn't seem to change anything. Whether I press 'OK' or 'Cancel' the actual file content of the project file, doesn't change or revert (if I press 'Cancel' and close). When reloaded the qgs-file always shows the correct status (= the project stats when the Python save-command was executed).
The date/time in the message seems to refer to the date I originally saved the project file via the QGIS 'Save Button'.
If I press the save button again the message won't appear again (until I use the python save-command). Also, if I save the project via python, then close the project, reload it and press the QGIS 'Save Button' the message won't appear.
How can I save a QGIS project file and use the QGIS 'save button' afterwards without this message showing up?
QgsProject.instance()
. Something like:from PyQt4.QtGui import QAction
;iface.mainWindow().findChild( QAction, 'mActionSaveProject' ).trigger()
file = QFileInfo(output_path)
project.write(file)