[QGIS-Developer] Dirtying project within model classes or not

Julien Cabieces julien.cabieces at oslandia.com
Mon Nov 3 08:45:08 PST 2025


Hi all,

I recently faced a strong disagreement about a design question that I
would like to discuss so we could take a decision on what it's best
to do.

The discussion starts here [0]

According to Nyall:

"dirtying is a gui/app level operation, which should only occur as a
direct result of user operations (as opposed to say a
script/plugin/process calling a particular piece of API)"

I strongly disagree, I think setDirty() calls should be made within model
classes, not in widgets. A plugin script that would modify a model object
expects the project to be dirty. If not, modifications made by the
script could simply be lost when closing the project without even
prompting user about unsaved modifications.

In several (most?) occasions (here for instances [1], [2]) it's done in the model part, but
there are actually some where it was not the case. I was considering
those as issues, but it seems that we have different view on the matter.

So, I'd like to know if we should:
- always dirty the project within model classes
- never dirty the project within model classes
- it depends...

Regards,
Julien

[0] https://github.com/qgis/QGIS/pull/63498#discussion_r2425462712
[1] https://github.com/qgis/QGIS/blob/275c7d4466f5df99f7a7467d3331ce11a7394b8d/src/core/project/qgsproject.cpp#L490
[2] https://github.com/qgis/QGIS/blob/275c7d4466f5df99f7a7467d3331ce11a7394b8d/src/core/project/qgsproject.cpp#L975

-- 

Julien Cabieces
Senior Developer at Oslandia
julien.cabieces at oslandia.com


More information about the QGIS-Developer mailing list