Skip to content
Permalink
Browse files

Merge pull request #4533 from boundlessgeo/too_many_dbmanager_errors_…

…fix#15868

[db_manager] catch exception when item has lost reference. for 2.18 regression fixes #15868
  • Loading branch information
slarosa committed May 30, 2017
2 parents 6c84b6e + b365293 commit 7266410aced292bd9cacdfe5bc3c59c91adf1a89
Showing with 7 additions and 5 deletions.
  1. +1 −1 python/plugins/db_manager/db_tree.py
  2. +6 −4 python/plugins/db_manager/layer_preview.py
@@ -164,7 +164,7 @@ def addLayer(self):
layers = QgsMapLayerRegistry.instance().addMapLayers([layer])
if len(layers) != 1:
QgsMessageLog.logMessage(
self.tr("%1 is an invalid layer - not loaded").replace("%1", layer.publicSource()))
self.tr("%1 is an invalid layer - not loaded").replace("%1", layer.publicSource()), "DBManagerPlugin")
msgLabel = QLabel(self.tr(
"%1 is an invalid layer and cannot be loaded. Please check the <a href=\"#messageLog\">message log</a> for further info.").replace(
"%1", layer.publicSource()), self.mainWindow.infoBar)
@@ -25,7 +25,7 @@
from qgis.PyQt.QtWidgets import QApplication

from qgis.gui import QgsMapCanvas, QgsMapCanvasLayer, QgsMessageBar
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry, QgsProject
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry, QgsProject, QgsMessageLog

from .db_plugins.plugin import Table

@@ -78,11 +78,13 @@ def setDirty(self, val=True):
def _clear(self):
""" remove any layers from preview canvas """
if self.item is not None:
## skip exception on RuntimeError fixes #6892
try:
self.item.aboutToChange.disconnect(self.setDirty)
except RuntimeError:
pass
## skip exception on RuntimeError fixes #6892
## skip TypeError and generic Exceptions fixes #15868
## generally due the remove of self.item object or C++ referenced object
except Exception as ex:
QgsMessageLog.logMessage(unicode(ex), "DBManagerPlugin")

self.item = None
self.dirty = False

0 comments on commit 7266410

Please sign in to comment.
You can’t perform that action at this time.