qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.6k stars 3.01k forks source link

No more styles after duplicate layer and change filter in query builder in 3.22.6 #48467

Open MarshalMappers opened 2 years ago

MarshalMappers commented 2 years ago

What is the bug or the crash?

Starting with QGIS Version 3.22.6 LTR. When you duplicate a Layer from geopackage and change the filter, e.g. "fid = 1", there seems to be all styles in geopackage are deletet. If you restart the geopackage, the styles are back in geopackage.

Steps to reproduce the issue

First of all you need a geopackage, with a (point) layer with one feature and at least one saved style in the geopackage.

  1. Load Layer in QGIS Projekt (Version 3.22.6)
  2. Save projekt and reopen it
  3. Double-click layer and go to "Source" --> "Style" --> "Load Style" --> switch "Load style" to "From Database (GeoPackage)" and make sure there is at least one style in the geopackage
  4. Cancel window "Database Style Manager"
  5. Cancel "Layer Properties"
  6. Right-Click layer and choose "Duplicate Layer"
  7. Double-Click the duplicated layer and go to "Source" --> "Style" --> "Load Style" and make sure there is at least one style in the geopackage
  8. Cancel window "Database Styles Manager"
  9. Click "Query Builder" and set a filter for the layer. E.g. "fid = 1"
  10. Click "OK" in "Query Builder"
  11. Click "OK" in "Layer Properties"
  12. Double-Click the duplicated layer
  13. Go to "Style" --> "Load Style" --> now there are no more styles in the geopackage visible
  14. Cancel all windows and restart the project
  15. Double click the layer and go to "Styles" --> "Load Styles" the styel will be available again

Versions

QGIS version | 3.22.6-Białowieża | QGIS code revision | b6f33b1a -- | -- | -- | -- Qt version | 5.15.2 Python version | 3.9.5 GDAL/OGR version | 3.4.2 PROJ version | 9.0.0 EPSG Registry database version | v10.054 (2022-02-13) GEOS version | 3.10.2-CAPI-1.16.0 SQLite version | 3.38.1 PDAL version | 2.3.0 PostgreSQL client version | 13.0 SpatiaLite version | 5.0.1 QWT version | 6.1.3 QScintilla2 version | 2.11.5 OS version | Windows 10 Version 2009   |   |   |   Active Python plugins Foto_einlesen | 0.104 mapswipetool_plugin | 1.2 mmqgis | 2021.9.10 neue_flaechen | 1.0 Beta neue_linien | 1.0 Beta neue_notiz_punkte | 0.1 nominatim | 1.4.1 pluginbuilder3 | 3.2.1 plugin_reloader | 0.8.2 db_manager | 0.1.20 grassprovider | 2.12.99 MetaSearch | 0.3.5 processing | 2.12.99 sagaprovider | 2.12.99 QGIS version 3.22.6-Białowieża QGIS code revision [b6f33b1a](https://github.com/qgis/QGIS/commit/b6f33b1a) Qt version 5.15.2 Python version 3.9.5 GDAL/OGR version 3.4.2 PROJ version 9.0.0 EPSG Registry database version v10.054 (2022-02-13) GEOS version 3.10.2-CAPI-1.16.0 SQLite version 3.38.1 PDAL version 2.3.0 PostgreSQL client version 13.0 SpatiaLite version 5.0.1 QWT version 6.1.3 QScintilla2 version 2.11.5 OS version Windows 10 Version 2009 Active Python plugins Foto_einlesen 0.104 mapswipetool_plugin 1.2 mmqgis 2021.9.10 neue_flaechen 1.0 Beta neue_linien 1.0 Beta neue_notiz_punkte 0.1 nominatim 1.4.1 pluginbuilder3 3.2.1 plugin_reloader 0.8.2 db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.5 processing 2.12.99 sagaprovider 2.12.99 ### Supported QGIS version - [X] I'm running a supported QGIS version according to the roadmap. ### New profile - [X] I tried with a new QGIS profile ### Additional context _No response_
DelazJ commented 2 years ago

Foto_einlesen 0.104 mapswipetool_plugin 1.2 mmqgis 2021.9.10 neue_flaechen 1.0 Beta neue_linien 1.0 Beta [...] New profile -[x] I tried with a new QGIS profile

@MarshalMappers Did you really try with a new user profile? Might help to exclude third-party plugins potential effects...

MarshalMappers commented 2 years ago

Yes, I really tried with a new use profile. I also tried on another computer. No problems with 3.22.5. Starts with 3.22.6. Do you have problems to reproduce the bug?

elpaso commented 2 years ago

I cannot reproduce on 3.24.2 and on master.

MarshalMappers commented 2 years ago

With the exact steps described above and with new user profile I still can reproduce this bug on 3.24.3. Hopefully it will be fixed soon. Also in long term release.

elpaso commented 2 years ago

I tried again but I cannot reproduce, sorry.

thbaumann commented 2 years ago

I can reproduce the error in QGIS 3.22 and 3.26 but only with files stored on a local drive (WAL mode on). If i duplicate the layer and set the filter then the wal and shm files are created and the style is not found. If I close the project the wal and shm files are deleted and so the style is found again for the duplicated layer when opening the project. With geopackages stored on network drives (default wal mode off) i cannot reproduce the error. When the wal and shm files are created QGIS skips the part where the list of available styles is created as hfeature is null: ( https://github.com/qgis/QGIS/blob/master/src/core/providers/ogr/qgsogrprovidermetadata.cpp#L788 ) grafik

If there are no wal/shm files created/active there is a hfeature object and thus the list of available styles is filled: grafik

MarshalMappers commented 2 years ago

I made a video of the bug with the latest ltr (3.22.11). Here is the link: https://youtu.be/BPG-aFz5Rn0 (the video is not listed). Hopefully with this information you can reproduce and fix the bug.

thbaumann commented 2 years ago

One more thing I noticed: With linux as OS i cannot reproduce the error, only when working with Windows (10).