Repository: napari/napari

Issue:
Massive traceback when deleting a (markers) layer
## 🐛 Bug

Sorry, no time to investigate now, but here is the traceback I saw when deleting a markers layer (using the trash icon):

<details>

```pytb
In [15]: WARNING: Traceback (most recent call last):
  File "/Users/jni/conda/envs/36/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/__init__.py", line 125, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/terminal/ipapp.py", line 356, in start
    self.shell.mainloop()
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 480, in mainloop
    self.interact()
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 463, in interact
    code = self.prompt_for_code()
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 376, in prompt_for_code
    pre_run=self.pre_prompt, reset_current_buffer=True)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/prompt_toolkit/interface.py", line 415, in run
    self.eventloop.run(self.input, self.create_eventloop_callbacks())
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/prompt_toolkit/eventloop/posix.py", line 102, in run
    self._inputhook_context.call_inputhook(ready)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/prompt_toolkit/eventloop/inputhook.py", line 74, in call_inputhook
    self.inputhook(self)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 495, in inputhook
    self._inputhook(context)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/IPython/terminal/pt_inputhooks/qt.py", line 35, in inputhook
    event_loop.exec_()
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/components/_layers_list/model.py", line 182, in remove_selected
    self.pop(i)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/util/list/_model.py", line 55, in pop
    self.changed.removed(item=obj)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/util/event.py", line 489, in __call__
    self._invoke_callback(cb, event)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/util/event.py", line 504, in _invoke_callback
    cb(event)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/components/_layers_list/model.py", line 29, in _remove
    layer.viewer = None
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/layers/_base_layer/model.py", line 162, in viewer
    self._parent = parent
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/layers/_base_layer/_visual_wrapper.py", line 82, in _parent
    self._node.parent = parent
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/util/frozen.py", line 17, in __setattr__
    object.__setattr__(self, key, value)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/scene/node.py", line 209, in parent
    self._update_trsys(None)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/napari/_vispy/scene/visuals.py", line 82, in _update_trsys
    self.transforms.scene_transform = scene.node_transform(doc)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/visuals/transforms/transform_system.py", line 276, in scene_transform
    self._scene_transform.transforms = tr
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/visuals/transforms/chain.py", line 96, in transforms
    self.update()
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/visuals/transforms/base_transform.py", line 153, in update
    self.changed(*args)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/util/event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    cb(event)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/visuals/transforms/chain.py", line 212, in _subtr_changed
    self.update(ev)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/visuals/transforms/base_transform.py", line 153, in update
    self.changed(*args)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/util/event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/util/event.py", line 475, in _invoke_callback
    self, cb_event=(cb, event))
  << caught exception here: >>
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    cb(event)
  File "/Users/jni/conda/envs/36/lib/python3.6/site-packages/vispy/visuals/transforms/chain.py", line 281, in source_changed
    new_tr = [tr[0]]
IndexError: list index out of range
ERROR: Invoking <bound method SimplifiedChainTransform.source_changed of <ChainTransform [<STTransform scale=[1. 1. 1. 1.] translate=[0. 0. 0. 0.] at 0x5071730616>,
                 <STTransform scale=[2.6181054e+00 2.6181054e+00 1.0000000e-06 1.0000000e+00] translate=[-558.83954 -403.84387    0.         0.     ] at 0x5319047544>] at 0x12e27aba8>> for Event
```

</details>

## To Reproduce

Approximately: (not sure which bits are important, maybe only the final step matters)
- add a (3D) image
- add a second image (segmentation in this case)
- decrease opacity of second image
- add a markers layer (with the + button)
- set annotation mode
- pan and zoom while holding down space
- hit the delete button.

## Expected behavior

Console should stay nice and clean when layers are deleted. ;)

## Environment

 - napari Version (e.g., 1.0): 0.0.6 (from PyPI)
 - OS (e.g., Linux): macOS Mojave
 - Python version: 3.6
 - Any other relevant information:



Discussion:
Ah yes - this is known, but thanks for adding. I havn't dug into it yet, but really need to!

Resolving patch:
diff --git a/napari/components/layerlist.py b/napari/components/layerlist.py
--- a/napari/components/layerlist.py
+++ b/napari/components/layerlist.py
@@ -2,6 +2,7 @@
 
 from ..util.naming import inc_name_count
 from ..util.list import ListModel
+from vispy.visuals.transforms import ChainTransform
 
 
 def _add(event):
@@ -19,6 +20,7 @@ def _remove(event):
     layers = event.source
     layer = event.item
     layer._order = 0
+    layer._node.transforms = ChainTransform()
     layer._node.parent = None
 
 


Test patch: