Commit 411367eb55747f7385502bd9477510000e60a502
1 parent
5bba7430
Exists in
command-line
Checking surface index exists in actors_dict before removing it
Showing
1 changed file
with
9 additions
and
8 deletions
Show diff stats
invesalius/data/surface.py
@@ -180,14 +180,15 @@ class SurfaceManager(): | @@ -180,14 +180,15 @@ class SurfaceManager(): | ||
180 | if selected_items: | 180 | if selected_items: |
181 | for index in selected_items: | 181 | for index in selected_items: |
182 | proj.RemoveSurface(index) | 182 | proj.RemoveSurface(index) |
183 | - actor = old_dict[index] | ||
184 | - for i in old_dict: | ||
185 | - if i < index: | ||
186 | - new_dict[i] = old_dict[i] | ||
187 | - if i > index: | ||
188 | - new_dict[i-1] = old_dict[i] | ||
189 | - old_dict = new_dict | ||
190 | - Publisher.sendMessage('Remove surface actor from viewer', actor) | 183 | + if index in old_dict: |
184 | + actor = old_dict[index] | ||
185 | + for i in old_dict: | ||
186 | + if i < index: | ||
187 | + new_dict[i] = old_dict[i] | ||
188 | + if i > index: | ||
189 | + new_dict[i-1] = old_dict[i] | ||
190 | + old_dict = new_dict | ||
191 | + Publisher.sendMessage('Remove surface actor from viewer', actor) | ||
191 | self.actors_dict = new_dict | 192 | self.actors_dict = new_dict |
192 | 193 | ||
193 | if self.last_surface_index in selected_items: | 194 | if self.last_surface_index in selected_items: |