Bug report #17670

Profiles do not pick up 'default options', even when shown in Options Dialog (eg Help Search Path)

Added by Richard Duivenvoorde over 2 years ago. Updated over 2 years ago.

Status:Closed
Priority:Normal
Assignee:Alessandro Pasotti
Category:Project Loading/Saving
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:not reproducable
Crashes QGIS or corrupts data:No Copied to github as #:25567

Description

Trying to fix the 'Oops No Help File Found' issue (see also https://github.com/qgis/QGIS/pull/5844) it appears to me that some 'options' which show up in the options DIALOG are actually not stored in the settings.
This makes that this test to find Documentation paths fail:
https://github.com/qgis/QGIS/blob/master/src/gui/qgshelp.cpp#L44

To check:
- make sure you do not have any profiles (so remove .local/share/QGIS)
- start QGIS
- have a look into Options/System/Documentation paths and see that there is an option:
http://docs.qgis.org/$qgis_short_version/$qgis_locale/docs/user_manual/
there
- have a look into the Options/Advanced/Advanced Settings Editor and see that there is NOT a key
"help/helpSearchPath" in the settings.

The options dialog is filled here:
https://github.com/qgis/QGIS/blob/master/src/app/qgsoptions.cpp#L302
so for that reason you see "http://docs.qgis.org/$qgis_short_version/$qgis_locale/docs/user_manual/" in the dialog.

So Question: how do we make sure that these 'default' options show up both in dialogs AND in the settings, ALSO when a new fresh profile is created
See #17598

Another question: WHEN you start with a clean default profile, should a second clean profile not have the same settings then?
In attached image I start a fresh default (left) and a fresh 'secondprofile' right. As you see the settings are very different.

2profiles.png - Settings of: left: fresh default profile, right fresh second profile (83.6 KB) Richard Duivenvoorde, 2017-12-11 02:36 PM

xyz.jpg (30.1 KB) Richard Duivenvoorde, 2018-01-10 05:00 PM


Related issues

Related to QGIS Application - Bug report #17598: User profile other than default does not find the online ... Closed 2017-11-30

Associated revisions

Revision f4094af6
Added by Alexander Bruy over 2 years ago

add default help location to the global settings (refs #17670)

History

#1 Updated by Richard Duivenvoorde over 2 years ago

Just a note that starting with a fresh profile, you will never be able to open the help pages as this settings value is never set it seems (thought the url in the options is ok)

#2 Updated by Richard Duivenvoorde over 2 years ago

  • Related to Bug report #17598: User profile other than default does not find the online documentation added

#3 Updated by Nathan Woodrow over 2 years ago

This is mainly a issue because those defaults are not created until you open and save the options dialog. I suspect this is the same as QGIS 2 so it's not profile related. The solution to anything that is shipped out of the box as a default should not be done in code and setup in qgis_global_settings.ini which is read only and all profiles will get it unless they override. That should be used for anything we want to ship out of the box

It's that or we have a setup config step which can load all defaults in code when the application first runs. That would be easy enough to do really and can just be part of the load process in main.

#4 Updated by Richard Duivenvoorde over 2 years ago

@nathan: I think a 'load/save all defaults to the settings in this profile' is a good one.

Though still I am afraid that IF people create a setting in some place, and then use it in another place (like with the help path: set in options, and use in help) we should in one way or another 'force' the default into settings?

Like:

  settings.value( QStringLiteral( "qgis/mysetting" ), false )

should set this default in the Settings if it is there not yet? Meaning that in QgsSetting.value(...) we do a small test. In this way during the use of QGIS, at least all settings are set to default values.

I thought of having a qgis_global_settings.ini first too, but the result of this is that the 'default' value is actually defined in two places: code and ini, with all problems of keeping this in sync.

The bigger future plan though should be that QGIS on a fresh install or on a fresh profile should have a well defined default start status. Be it via a master.ini or via a programming step.

#5 Updated by Matthias Kuhn over 2 years ago

I thought of having a qgis_global_settings.ini first too, but the result of this is that the 'default' value is actually defined in two places: code and ini, with all problems of keeping this in sync.

Or skip it in code and have QgsSettings load the global_settings.ini if it's missing from the profile?

#6 Updated by Richard Duivenvoorde over 2 years ago

@matthias and then make it impossible to set/use a default value in code? So devs are forced to set the default in global_settings.ini?

Not sure if that will fly. Sometimes you need a default value for an optional setting for which there is no need to really save into settings.

But being able to define a default setting both in code AND in ini file will result in a messy state in my opinion.

#7 Updated by Nathan Woodrow over 2 years ago

Global settings are already used this way. They are a fallback if it's not defined in the profile settings. What we really need is a way to generate the default starting global ini file that we have in git. Meaning we update the code, that generates a ini file we check-in into git and that is shipped.

#8 Updated by Nathan Woodrow over 2 years ago

and if a dev doesn't set a default in code and it's not found in settings then there isn't much else we can do. We could ship a list of "no delete defaults" that you can't override but not sure what stuff you would put in that bucket.

#9 Updated by Harrissou Santanna over 2 years ago

Ì don't know if it's related to this issue or if I should file a new report but profile doesn't pick its own language: I'd like to have a profile that is in English (eg quickly file screenshots for docs or issues) and a French one where i could do my daily work or find missing or wrong translation.
Currently, both profiles pick the latest status of the "Override system locale" checkbox and not the one I set when using such profile.

#10 Updated by Jürgen Fischer over 2 years ago

  • Description updated (diff)

#11 Updated by Richard Duivenvoorde over 2 years ago

To test:
- remove ~/.share/local/QGIS
- start QGIS
- choose 'I want a clean start. Don't import my QGIS 2 settings.'

Now in Python console type:

QgsSettings().value( "help/helpSearchPath" )
which will return an emtpy list (of search paths)

Open Settings/Options/System properties and see there is:
https://docs.qgis.org/$qgis_short_version/$qgis_locale/docs/user_manual/
in Documentation paths there.

NOW click OK and NOW we have a saved help/helpSearchPath value:

QgsSettings().value( "help/helpSearchPath" )

['https://docs.qgis.org/$qgis_short_version/$qgis_locale/docs/user_manual/']

#12 Updated by Alessandro Pasotti over 2 years ago

As Nathan mentioned, global_settings is meant to provide defaults and IMHO it is the way to go, we should move defaults from code to the global_settings and ship it.

The idea is that it is better/easier to keep default values in a single file, that allows for easier customization during packaging and does not force to rebuild the whole binary distribution in order to alter a default setting.

settings.value('whatever') will read the global_settings if nothing is found in the user (profile) settings.

The order in which values are retrieved from value() is the following:

1. the value in the user profile settings
2. the value in the global_settings (note that this has precedence over the next)
3. the default provided inline in the code as an optional argument to value(), like settings.value('whatever', 'default')
4. QVariant() // empty-invalid

#13 Updated by Richard Duivenvoorde over 2 years ago

Ok, some additional info:

There IS already an qgis_global_settings.ini file

QgsApplication.pkgDataPath() + "/qgis_global_settings.ini" 

which is in my case rightfully installed in my (custom) install directory.
This file contains (with me) currently the xyz-url for osm.
BUT if you start QGIS for the first time, after

rm -rf ~/.local/share/QGIS

this file is apparently not read/handled as the xyz-node in the browser will be empty (see screenshot).
The second time you start QGIS, it is read, as at THAT time the xyz node contains the osm connection.
So this seems to be a bug in the handling of the qgis_global_settings.ini in the first run.

The QgsSettings().value( "help/helpSearchPath" ) though, stays empty untill you OK the Settings/Options dialog.

IF we would put that setting in qgis_global_settings.ini though, it would show up (the second time ;-) )

#14 Updated by Alessandro Pasotti over 2 years ago

The issue with XYZ defaults (that are actually in the global_settings.ini that we ship) is that at the time the global file path to search is generated, QgsApplication.pkgDataPath() is empty because QgsApplication::init() has not been called yet.

This means that the global_settings is not found.

Broken by 00dbc73d430f013d2bcd9bd4b3d5f0d14319f64f

#15 Updated by Richard Duivenvoorde over 2 years ago

Another additional observation: if you create a new profile, it looks like the global_settings.ini are never read. Because multiple opening of QGIS with the second profile will never show the xyz url...

#16 Updated by Alessandro Pasotti over 2 years ago

  • Assignee set to Alessandro Pasotti

#17 Updated by Richard Duivenvoorde over 2 years ago

https://github.com/qgis/QGIS/pull/6303 is adding the help url to the global settings

#19 Updated by Alessandro Pasotti over 2 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed
  • Pull Request or Patch supplied changed from No to Yes

#20 Updated by Richard Duivenvoorde over 2 years ago

  • Status changed from Closed to Reopened

@Alessandro and @Nathan, in my testing it is still not solved.

Creating a fresh profile, people will have no help and xyz layer.

Only after:
- opening options dialog + OK'ing it the help url setting will be available
- shutting down and restarting QGIS will get the user the xyz layer setting

#21 Updated by Alessandro Pasotti over 2 years ago

  • Status changed from Reopened to Closed
  • Resolution changed from fixed/implemented to not reproducable

Also available in: Atom PDF