Skip to content

Commit

Permalink
Do not try to update link if it is being deleted. Fixes #2483.
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Jun 6, 2018
1 parent 0de6bfe commit 6ab2d63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 18 additions & 2 deletions gns3/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, source_node, source_port, destination_node, destination_port,
self._destination_label = None
self._link_id = link_id
self._capturing = False
self._deleting = False
self._capture_file_path = None
self._capture_file = None
self._initialized = False
Expand Down Expand Up @@ -158,7 +159,7 @@ def addPortLabel(self, port, label):
self._updateLabels()

def update(self):
if not self._link_id:
if not self._link_id or self.deleting():
return
body = self._prepareParams()
Controller.instance().put("/projects/{project_id}/links/{link_id}".format(project_id=self._source_node.project().id(), link_id=self._link_id), self.updateLinkCallback, body=body)
Expand Down Expand Up @@ -244,6 +245,19 @@ def _linkCreatedCallback(self, result, error=False, **kwargs):
def link_id(self):
return self._link_id

def deleting(self):
"""
Is the link being deleted
"""
return self._deleting

def setDeleting(self):
"""
Mark this link as being deleted
"""

self._deleting = True

def capturing(self):
"""
Is a capture running on the link?
Expand Down Expand Up @@ -306,8 +320,10 @@ def deleteLink(self, skip_controller=False):
if skip_controller:
self._linkDeletedCallback({})
else:
self.setDeleting()
Controller.instance().delete("/projects/{project_id}/links/{link_id}".format(project_id=self.project().id(),
link_id=self._link_id), self._linkDeletedCallback)
link_id=self._link_id),
self._linkDeletedCallback)

def _linkDeletedCallback(self, result, error=False, **kwargs):
"""
Expand Down
2 changes: 2 additions & 0 deletions gns3/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ def delete(self, skip_controller=False):
"""

if not skip_controller:
for link in self.links():
link.setDeleting()
self.controllerHttpDelete("/nodes/{node_id}".format(node_id=self._node_id), self._deleteCallback)
else:
self.deleted_signal.emit()
Expand Down

0 comments on commit 6ab2d63

Please sign in to comment.