Skip to content

Commit

Permalink
Merge pull request #4533 from boundlessgeo/too_many_dbmanager_errors_…
Browse files Browse the repository at this point in the history
…fix#15868

[db_manager] catch exception when item has lost reference. for 2.18 regression fixes #15868
  • Loading branch information
slarosa authored May 30, 2017
2 parents 6c84b6e + b365293 commit 7266410
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions python/plugins/db_manager/layer_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7266410

Please sign in to comment.