Bug report #21409
do not rewrite system variables from global_settings.ini file in the QGIS.ini user parameter file
|Affected QGIS version:||3.4.5||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||Yes||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||29226|
I'm not sure it's a bug, but it's a problem for centralized parameter management.
if the user adds a custom variable, all variables are rewritten in QGIS.ini
Any future changes to the relevant variables in the global_settings are no longer taken into consideration.
QGIS reading the QGIS.ini after the global_settings.ini
#2 Updated by Alain FERRATON almost 2 years ago
It is not a question of preventing a user from overwriting a parameter with his own values if it is a deliberate act.
But the system as it is currently designed freezes all parameters in the QGIS.INI if only one change is made by a user. Any later changes to the default settings in the global_settings are then no longer taken into account, except for the addition of new variables.
#6 Updated by Alain FERRATON almost 2 years ago
The example I am confronted with is the following:
we add in global_settings a path to a plugin directory:
if the user adds a variable to describe a service name for its layout. All variables, including QGIS_PLUGINPATH are written in QGIS.INI
If QGIS_PLUGINPATH is modified in global_settings, the new value is overwritten by the value stored in QGIS.INI
#8 Updated by Alessandro Pasotti almost 2 years ago
- Status changed from Feedback to In Progress
- Pull Request or Patch supplied changed from No to Yes
If you want you can add your opinion there: this is really a change in the behavior of the QgsSettings system more than a bug fix.
#10 Updated by Alain FERRATON almost 2 years ago
Finally I am not sure that the proposed patch solves my particular case.
Indeed, if a user adds a custom variable, he modifies custEnvVars.
The test line 287 will therefore be true and QGIS_PLUGINPATH will be stored in QGIS.ini.
What do you think about?
#11 Updated by Alessandro Pasotti almost 2 years ago
Sorry but I don't understand: if the user adds/modify custEnvVars (on any other setting) it will be stored in the user settings and the defaults from global settings will not be used.
That's the idea behind the global settings: to be able to provide default values.
For any other settings manipulation you'd need more sophisticated approaches, I did some work on that in the past, you need to start from a startup.py script that manipulates the user settings before QGIS starts.
#12 Updated by Alain FERRATON almost 2 years ago
The difficulty with custom environment variables is that you may want some to be stored in global_setting.ini while leaving the user the option to add their own.
Unfortunately QGIS stores all environment variables as a single string in CustEnvVars which is therefore necessarily in QGIS.INI as soon as the user adds a local variable.
I understand that this is sophisticated approache.
Startup.py may be a solution...
I am interested by examples if they exist....
#13 Updated by Alessandro Pasotti almost 2 years ago
This is my old work: https://connect.boundlessgeo.com/docs/desktop/latest/system_admins/init_scripts.html it was developed for QGIS 2 but you get the idea.