Copy the list of selected nodes and edges so that we don't conflict with selection updating the list.
Fixes #2841

Change-Id: Ia4b846eb002b71882e766449335b9005d0207db5