Bug report #12938
DB Manager adds invisible layers to TOC during layer preview and doesn't remove them after it is closed
|Affected QGIS version:||2.8.2||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||21018|
Open DB Manager, connect to the PostgGIS database (haven't testet on Spatialite), select table that have geometry column and click on preview tab. DB Manager shows the preview of the vector layer and at the same time this layer is silently added to current QGIS TOC. This layer doesn't appear in TOC for user, but is retrieved if TOC content is queryed using Python. If user selects another table with geometry column and preview it DB Manager, new table will be added to TOC the same way and the first one will remain. Both table names will remain (unseen to user) in TOC even after the DB Manager is closed. On closing DB Manager the exeption runtime error is raised, see log:
>>>def laylist(): >>> l= >>> for layer in QgsMapLayerRegistry.instance().mapLayers().values(): >>> item = layer.name() >>> l.append(item) >>> print l # There is only one layer 'buf' (a shp-file) in QGIS TOC. Check the TOC >>>laylist() [u'buf'] # Now open DM Manager, connect to the PostGIS DB and preview one of the spatially enabled tables ('park_kvartal3_utm') without adding them to TOC # Check TOC again: >>>laylist() [u'park_kvartal3_utm', u'buf'] # Now in DB Manager select another spatial table ('itog_region_utm') and preview it without adding it to TOC >>>laylist() [u'park_kvartal3_utm', u'itog_region_utm', u'buf'] # Close DB Manager and catch exception. Exception RuntimeError: 'wrapped C/C++ object of type PGVectorTable has been deleted' in <bound method PGTableDataModel.__del__ of <db_manager.db_plugins.postgis.data_model.PGTableDataModel object at 0x7f17550dedf8>> ignored # Check TOC content again after the DB Manager is closed. Notice: no layer was added to TOC by user during DB Manager session. The names of table remains: >>>laylist() [u'park_kvartal3_utm', u'itog_region_utm', u'buf']
Ideally these names shouldn't be added to TOC at all.
#2 Updated by Giuseppe Sucameli about 5 years ago
- OS version deleted (
- Operating System deleted (
- Assignee set to Giuseppe Sucameli
That's layer registry, not TOC...
Anyway layers must be removed either once the preview changes or the DBManager main window is closed.
I'm looking at it.