code: def on_selection_changed(self):
          
          d = self.declaration
          selection = self.scene.selectedItems()
          self._guards |= 0x01
          try:
              d.selected_items = [item.ref().declaration for item in selection
                                  if item.ref()]
          finally:
              self._guards &= ~0x01
docs: Callback invoked one the selection has changed.