Bug report #19651
Style loading issue
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | Alessandro Pasotti | ||
Category: | Symbology | ||
Affected QGIS version: | 3.3(master) | Regression?: | Yes |
Operating System: | Kubuntu 18.02 | Easy fix?: | No |
Pull Request or Patch supplied: | Yes | Resolution: | fixed/implemented |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 27477 |
Description
Loading styles from .QML files fail when a style is stored into DB. If more than one style is stored into DB, it is only possible to switch between them (through QGIS GUI) and one is taken as 'default', not allowing API calls to act.
Associated revisions
Load style from QML when provider supports stored styles
Fixes #19651 - Style loading issue
History
#1 Updated by Giovanni Manghi over 6 years ago
- Status changed from Open to Feedback
- Category changed from Map Canvas to Symbology
The animated gif is very... fast and not sure I understand the description: "loading a QML style fails if to the vector was applied a style loaded from db?" is that correct?
if yes, does works as expected on QGIS LTR (2.18)?
#2 Updated by joao esperidiao over 6 years ago
Giovanni Manghi wrote:
The animated gif is very... fast and not sure I understand the description: "loading a QML style fails if to the vector was applied a style loaded from db?" is that correct?
if yes, does works as expected on QGIS LTR (2.18)?
Sorry, it indeed is not very clear.
The issue is: I'm unable to change a layer style read from a .QML file if there is already a style for this layer stored into dabatase (the layer is read from that same database).
When multiple styles are available (stored into database) for a layer, QGIS seems to default a style for it (the first to be applied after they are stored) and any attempt to swap the applied style from a file is frustrated - the default style is applied instead.
The API part is referred because the default behavior is replicated when using QgsMapLayer::loadNamedStyle (that might be me not using the method properly, though). This was noticed when using a tool from a plugin I work on, which did work nicely on LTR.
I hope it is a bit clearer!
Cheers!
#3 Updated by Alessandro Pasotti over 6 years ago
- Status changed from Feedback to Closed
- Resolution set to invalid
You need to pass "True" as last argument to the call:
layer.loadNamedStyle('/home/xxx/dev/QGIS/tests/src/python/bug_19651_test.qml', True)
#4 Updated by joao esperidiao over 6 years ago
Alessandro Pasotti wrote:
You need to pass "True" as last argument to the call:
layer.loadNamedStyle('/home/xxx/dev/QGIS/tests/src/python/bug_19651_test.qml', True)
The "True" arg does sort the issue from my Plugin perspective, thank you. However, the issue I tried to point out can be reproduced as follows:
1- set a style for a layer (loaded from a database);
2- store that style in its database;
3- load it;
4- change that style (just for visualization purposes) and save it as a .QML file;
5- load back the original style from database (or any other style, the point is to note the difference between styles); and
6- try to load the style from the .QML file.
At the end of those steps, the loaded style should be the one you had chosen initially (the 'default'), from the database, instead of the actual style stored into that .QML file (maybe it is also missing the 'True' arg there?).
Cheers,
#5 Updated by Alessandro Pasotti over 6 years ago
Sorry but I don't understand: I think that the expected behavior after
6- try to load the style from the .QML file
is that the applied style is whatever it is in that .QML file.
#6 Updated by joao esperidiao over 6 years ago
Alessandro Pasotti wrote:
Sorry but I don't understand: I think that the expected behavior after
6- try to load the style from the .QML file
is that the applied style is whatever it is in that .QML file.
Yes, precisely. I guess I'm terrible at making myself understood. The expected behavior is to load whatever it is inside the .QML, but it does not load that. The actual behavior is that the style loaded at first from database is loaded instead of the .QML content.
#7 Updated by Giovanni Manghi over 6 years ago
- Priority changed from Normal to High
- Resolution deleted (
invalid) - Regression? changed from No to Yes
- Status changed from Closed to Open
joao esperidiao wrote:
Alessandro Pasotti wrote:
Sorry but I don't understand: I think that the expected behavior after
6- try to load the style from the .QML file
is that the applied style is whatever it is in that .QML file.
Yes, precisely. I guess I'm terrible at making myself understood. The expected behavior is to load whatever it is inside the .QML, but it does not load that. The actual behavior is that the style loaded at first from database is loaded instead of the .QML content.
Don't worry Joao, we are terrible at understand at times :)
Anyway... I can replicate your issue on QGIS master on the same platform (Kunbutu 18.02).
At/after step 6 it loads the default style saved in the DB instead of the style in the QML file.
If the default style is deleted from the DB the QML works as expected.
So seems really a regression compared to LTR.
#8 Updated by joao esperidiao over 6 years ago
Giovanni Manghi wrote:
joao esperidiao wrote:
Alessandro Pasotti wrote:
Sorry but I don't understand: I think that the expected behavior after
6- try to load the style from the .QML file
is that the applied style is whatever it is in that .QML file.
Yes, precisely. I guess I'm terrible at making myself understood. The expected behavior is to load whatever it is inside the .QML, but it does not load that. The actual behavior is that the style loaded at first from database is loaded instead of the .QML content.
Don't worry Joao, we are terrible at understand at times :)
Anyway... I can replicate your issue on QGIS master on the same platform (Kunbutu 18.02).
At/after step 6 it loads the default style saved in the DB instead of the style in the QML file.If the default style is deleted from the DB the QML works as expected.
So seems really a regression compared to LTR.
In that case, I do take the blame, though haha
Thanks! I'll keep an eye on the issue!
#9 Updated by Alessandro Pasotti over 6 years ago
- Assignee set to Alessandro Pasotti
#10 Updated by Alessandro Pasotti over 6 years ago
- Status changed from Open to In Progress
- Pull Request or Patch supplied changed from No to Yes
#11 Updated by Anonymous about 6 years ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
Applied in changeset qgis|f68de973eac19d89a437a9123bbdebe8c069101e.
#12 Updated by Giovanni Manghi about 6 years ago
- Resolution set to fixed/implemented