Bug report #16476
DB Manager: previewing layers in Virtual layers section remove them from the Layers panel
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||Yes||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||Yes||Copied to github as #:||24385|
Open a project
Launch DB Manager, expand the Virtual layers section, then QGIs layers and select a layer
Click the Preview tab
Select another layer
The layer you selected first has been removed from the Layers panel, hence from the project (GUI, at least)
Happens also in master
Set the report as high because this can easily corrupt the project if you don't notice the removal (and anyway, if you notice it, you'll need to close and not save the project to avoid it being corrupted)
#4 Updated by Luigi Pirelli about 4 years ago
the problem is a logic problem... the db_manager base class layer_preview remove from registry any previously added layer (currentLayer) with it's id, with assumption that it's id is a temporary layer because has been added for the preview.
virtual layer qgis layer is populated of all registry layers => also that are in the layer list, when you click on that it become current layer => it is removed when switching to another layer in db_manager
looking for a simple solution for that
#6 Updated by Luigi Pirelli about 4 years ago
- Pull Request or Patch supplied changed from No to Yes
fixed for 2.18 https://github.com/qgis/QGIS/pull/4534 waiting for review and merge, expecially review by Hugo Mercier.
fix for 3.0 will be delayed because actually in this version db_manager raise much more exception than the 2.18 or 2.14 one => I'll try to work in a general PR fixup most common one.