Skip to content

Commit

Permalink
Early return if no valid relation available
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Oct 7, 2024
1 parent 5a0526d commit 8b0a8b6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions linking_relation_editor/gui/linking_relation_editor_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,19 +774,20 @@ def zoomToSelectedFeatures(self):
def afterSetRelations(self):
self._nmRelation = QgsProject.instance().relationManager().relation(str(self.nmRelationId()))

if self.relation().isValid():
self._checkTransactionGroup()
if not self.relation().isValid():
QgsLogger.warning(self.tr(f"Invalid relation set, relation id: '{self.relation().id()}'"))
self.updateButtons()
return

self.relation().referencingLayer().editingStopped.connect(self.updateButtons)
self.relation().referencingLayer().editingStarted.connect(self.updateButtons)
self._checkTransactionGroup()

self.relation().referencingLayer().editingStopped.connect(self.updateButtons)
self.relation().referencingLayer().editingStarted.connect(self.updateButtons)

if self.nmRelation().isValid():
self.nmRelation().referencedLayer().editingStarted.connect(self.updateButtons)
self.nmRelation().referencedLayer().editingStopped.connect(self.updateButtons)

if not self.relation().isValid() and not self.nmRelation().isValid():
QgsLogger.warning(self.tr(f"No valid relation set. Relation id: '{self.relation().id()}' NM relation id: '{self.nmRelationId()}'"))

self.updateButtons()

def _checkTransactionGroup(self):
Expand Down

0 comments on commit 8b0a8b6

Please sign in to comment.