diff --git a/ai_diffusion/layer.py b/ai_diffusion/layer.py index e0d5ca63d..fd5d4802a 100644 --- a/ai_diffusion/layer.py +++ b/ai_diffusion/layer.py @@ -386,10 +386,6 @@ def update(self): return with self._update_guard(): - if active.uniqueId() != self._active_id: - self._active_id = active.uniqueId() - self.active_changed.emit() - removals = set(self._layers.keys()) changes = False for n in traverse_layers(root_node): @@ -408,6 +404,11 @@ def update(self): self.removed.emit(self._layers[id]) del self._layers[id] + active_id = active.uniqueId() + if active_id != self._active_id and active_id in self._layers: + self._active_id = active_id + self.active_changed.emit() + if removals or changes: self.changed.emit()