Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Styles" submenu no longer display all available styles by default for a given layer #57251

Closed
1 of 2 tasks
jfbourdon opened this issue Apr 25, 2024 · 4 comments · Fixed by #57273
Closed
1 of 2 tasks
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Regression Something which used to work, but doesn't anymore Styles

Comments

@jfbourdon
Copy link
Contributor

What is the bug or the crash?

All available styles for a given layer are no longer displayed by default in the "Styles" submenu. This feature was introduced in 3.30 (#50812) to fix #37434.

Style submenu in QGIS 3.30.2 and 3.32.2:
3 30 2

Style submenu in 3.34.4 and 3.36.0:
3 34 4

Steps to reproduce the issue

  1. Create a GPKG containing a layer with two associated styles
# Creation of the base layer
lyr = QgsVectorLayer("LineString?crs=EPSG:3857", "line", "memory")
wkt = 'LineString (0 0, 10 0, 5 5)'
geom = QgsGeometry.fromWkt(wkt)
fet = QgsFeature()
fet.setGeometry(geom)
lyr.dataProvider().addFeature(fet)

# Write layer as GeoPackage
path_gpkg = "C:/Temp/line.gpkg"
save_options = QgsVectorFileWriter.SaveVectorOptions()
QgsVectorFileWriter.writeAsVectorFormatV3(lyr, path_gpkg, QgsCoordinateTransformContext(), save_options)

# Store two different styles inside the GeoPackage
lyr = QgsVectorLayer(path_gpkg)
for color in ["red","blue"]:
    symbol = QgsLineSymbol.createSimple({'line_style': 'dash', 'color': color})
    lyr.renderer().setSymbol(symbol)
    lyr.saveStyleToDatabase(name=f"dash_{color}", description="", useAsDefault=False, uiFileContent="")
  1. Load in QGIS the resulting GeoPackage and check if the styles are directly available in the "Styles" submenu of the layer in the Layers Panel.

Versions

QGIS 3.34.4
QGIS 3.36.0

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@jfbourdon jfbourdon added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Apr 25, 2024
@agiudiceandrea agiudiceandrea added Styles Regression Something which used to work, but doesn't anymore labels Apr 27, 2024
@agiudiceandrea
Copy link
Contributor

@elpaso, you may be interested in this bug report.

@elpaso elpaso self-assigned this Apr 29, 2024
elpaso added a commit to elpaso/QGIS that referenced this issue Apr 29, 2024
@elpaso
Copy link
Contributor

elpaso commented Apr 29, 2024

This feature was introduced in 3.30 (#50812) to fix #37434.

Actually, that is not correct.

The root cause of the issue has been there for years, it has probably surfaced after my changes but here is a test with commit 1373d2b Merge pull request #50812 from elpaso/bugfix-gh37434-default-style-name, as you can see it works as expected:

immagine

@agiudiceandrea
Copy link
Contributor

@elapso, since your PR has been merged in 3.30.0, while the issue didn't occur using QGIS 3.30.2 or 3.32.2, it looks like some other PR may have been introduced the issue after your PR.

@elpaso
Copy link
Contributor

elpaso commented Apr 30, 2024

@elapso, since your PR has been merged in 3.30.0, while the issue didn't occur using QGIS 3.30.2 or 3.32.2, it looks like some other PR may have been introduced the issue after your PR.

Yes, that's is my conclusion too. Anyway, I've fixed it at least for GPKG where I've found the cause of the issue, if the problem is still present with other providers it may require a different fix.

nyalldawson pushed a commit that referenced this issue May 1, 2024
qgis-bot pushed a commit that referenced this issue May 1, 2024
qgis-bot pushed a commit that referenced this issue May 1, 2024
nyalldawson pushed a commit that referenced this issue May 1, 2024
nyalldawson pushed a commit that referenced this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Regression Something which used to work, but doesn't anymore Styles
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants