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

Editing/Modifying Virtual Layers #51777

Closed
2 tasks done
feldmrob opened this issue Feb 8, 2023 · 4 comments · Fixed by #51780
Closed
2 tasks done

Editing/Modifying Virtual Layers #51777

feldmrob opened this issue Feb 8, 2023 · 4 comments · Fixed by #51780
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@feldmrob
Copy link

feldmrob commented Feb 8, 2023

What is the bug or the crash?

Cannot edit existing virtual layer without triggering multiple problems which would all appear traceable to broken internal references to Layer ID.

First recognized failure relates to virtual layers with multiple associated styles. After edit, only active style remains. All additional style entries simply vanish.

Second failure occurs when editing a virtual layer that is referred to (not imported) by another virtual layer. Doing so appears to work during the active session, but upon saving and reopening project, the subject layer and all referring to it become unusable, only evidenced by vestigial layer legend entries. Right-clicking on legend entry brings up context menu sans "edit virtual layer" option.

Third failure confirms #51118, which breaks atlas layouts using edited virtual layer as coverage layer.

Steps to reproduce the issue

  1. Create virtual layer (based on ESRI shapefile in my case, unknown about other providers).
  2. Add at least two styles.
  3. Create another virtual layer with SQL SELECT FROM [virtual layer]
  4. Create print layout, designate it as atlas, select virtual layer as coverage layer.
  5. Modify virtual layer, click "Add," confirm "overwrite."
  6. Note apparent success as layer now appears as edited.
  7. Note loss of all except active style.
  8. Save, close and reopen file.
  9. Note both primary and referring virtual layers are gone from canvas, and layers panel entries now lack geometry symbol.
  10. Open print layout, select Atlas tab, note missing coverage layer selection.

To test theory that implicates Layer ID reference I manually edited only the SQL source of one layer in XML project source file, thus bypassing whatever updating happens in code. This works fine.

Versions

QGIS version
3.28.3-Firenze
QGIS code revision
c12bcb2
Qt version
5.15.3
Python version
3.9.5
GDAL/OGR version
3.6.2
PROJ version
11.1.1
EPSG Registry database version
v10.076 (2022-08-31)
GEOS version
3.11.1-CAPI-1.17.1
SQLite version
3.39.4
PDAL version
2.4.3
PostgreSQL client version
unknown
SpatiaLite version
5.0.1
QWT version
6.1.6
QScintilla2 version
2.13.1
OS version
Windows 10 Version 2009

Active Python plugins
batch_gps_importer
version 1.0.1
kmltools
3.1.27
LayerBoard
1.0.1
NNJoin
3.1.3
numericalDigitize
0.4.7
QuickOSM
2.1.1
quick_map_services
0.19.33
shapetools
3.4.9
SpreadsheetLayers
2.0.1
db_manager
0.1.20
MetaSearch
0.3.6
processing
2.12.99

Supported QGIS version

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

New profile

  • I tried with a new QGIS profile

Additional context

No response

@feldmrob feldmrob added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Feb 8, 2023
@roya0045
Copy link
Contributor

roya0045 commented Feb 8, 2023

Same source issue as #51118

@feldmrob
Copy link
Author

feldmrob commented Feb 8, 2023

Same source issue as #51118

Agreed, roya0045. With what I hope is helpful additional information, including the revelation that this behavior will do latent damage to multiple layers which you'll only learn have been essentially deleted the next time you open the project.

@nyalldawson nyalldawson self-assigned this Feb 9, 2023
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Feb 9, 2023
doesn't lose all the layer's properties

Fixes qgis#51118
Fixes qgis#51777
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Feb 9, 2023
doesn't lose all the layer's properties

Fixes qgis#51118
Fixes qgis#51777
qgis-bot pushed a commit that referenced this issue Feb 15, 2023
doesn't lose all the layer's properties

Fixes #51118
Fixes #51777
nyalldawson added a commit that referenced this issue Feb 17, 2023
doesn't lose all the layer's properties

Fixes #51118
Fixes #51777
benoitdm-oslandia pushed a commit to benoitdm-oslandia/QGIS that referenced this issue Feb 20, 2023
doesn't lose all the layer's properties

Fixes qgis#51118
Fixes qgis#51777
@feldmrob
Copy link
Author

Does not appear to be completely fixed. While attached styles and atlas references are now preserved, a virtual layer which refers to another virtual layer still appears to be forever entangled with that "donor" layer's ID. As such the most severe symptom persists with v3.30.

Specifically, even after modifying the "FROM" clause in a "recipient" layer to eliminate any reference to the "donor" layer, removing a "donor" layer (such as a duplicate you might have created to work around the original issue) silently breaks every virtual layer that ever referred to it.

As this does not manifest until the project is saved and reopened, restoration from backup is the only recovery option, which of course does not preserve all work from the last session.

@djes
Copy link

djes commented Apr 16, 2024

I have similar issues. As my project is complex, I cannot give an explanation by now, I'm just randomly loosing virtual layers on project save/load.

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!
Projects
None yet
4 participants