From 6fa8c524824ed0faf0a20042d9398d60db57624c Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 3 Oct 2016 16:35:07 +0200 Subject: [PATCH] Fix a bug when selecting a topology and deleting multiple linked device Fix https://github.com/GNS3/gns3-gui/issues/1554 --- gns3server/controller/project.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 6ce88470..25205441 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -33,6 +33,7 @@ from .udp_link import UDPLink from ..config import Config from ..utils.path import check_path_allowed, get_default_project_directory from ..utils.asyncio.pool import Pool +from ..utils.asyncio import locked_coroutine from .export_project import export_project from .import_project import import_project @@ -360,16 +361,23 @@ class Project: self.dump() return node - @open_required - @asyncio.coroutine - def delete_node(self, node_id): - - node = self.get_node(node_id) + @locked_coroutine + def __delete_node_links(self, node): + """ + Delete all link connected to this node. + The operation use a lock to avoid cleaning links from + multiple nodes at the same time. + """ for link in list(self._links.values()): if node in link.nodes: yield from self.delete_link(link.id) + @open_required + @asyncio.coroutine + def delete_node(self, node_id): + node = self.get_node(node_id) + yield from self.__delete_node_links(node) self.remove_allocated_node_name(node.name) del self._nodes[node.id] yield from node.destroy()