Skip to content

Commit

Permalink
Merge pull request #423 from opengisch/QF-1929-fix-fix
Browse files Browse the repository at this point in the history
Prevent python error popping up because of deleted QgsMapLayer
  • Loading branch information
suricactus authored Apr 28, 2022
2 parents e59baf9 + f9c646e commit bd79752
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions qfieldsync/gui/layers_config_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def __init__(self, project, use_cloud_actions, layer_sources, parent=None):

self.reloadProject()

def closeEvent(self, event):
if Qgis.QGIS_VERSION_INT >= 31900:
self.project.dirtySet.disconnect(self._on_dirtyset)

def get_available_actions(self, layer_source):
if self.use_cloud_actions:
return layer_source.available_cloud_actions
Expand Down Expand Up @@ -248,10 +252,19 @@ def toggleMenu_triggered(self, action):

def _on_dirtyset_wrapper(self):
def _on_dirtyset():
for layer_source in self.layer_sources:
layer_source.read_layer()

self.reloadProject()
# the layer might got deleted by the time dirtyset is called
try:
for layer_source in self.layer_sources:
layer_source.read_layer()

self.reloadProject()
except RuntimeError:
# just try to remove the dirtyset connection if possible
try:
if Qgis.QGIS_VERSION_INT >= 31900:
self.project.dirtySet.disconnect(self._on_dirtyset)
except RuntimeError:
pass

return _on_dirtyset

Expand Down

0 comments on commit bd79752

Please sign in to comment.