From ef4a9c56c5da9f039294cfc7e848a19a3c4b25cd Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 2 May 2017 13:00:51 -0700 Subject: [PATCH] Try to fix up `breakGroup`. With the new CursesReporter, I'm able to observe groups getting built and broken; and I observed that sometimes a Bond (between a Letter and a Group) would apparently survive the Group's breaking. Reorder the operations in `breakGroup` so that the higher-level ones ("detach this Group from its external bonds") come strictly before the lower-level ones ("ungroup this Group's members and remove this Group from the Workspace, thus destroying it"). However, the "buggy" behavior I observed turned out to be due to a bug in my display code and not due to anything wrong with `breakGroup`. I suspect this patch is actually purely cosmetic. --- copycat/group.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/copycat/group.py b/copycat/group.py index d91a937..58659bb 100644 --- a/copycat/group.py +++ b/copycat/group.py @@ -140,25 +140,26 @@ class Group(WorkspaceObject): def breakGroup(self): workspace = self.ctx.workspace + if self.correspondence: + self.correspondence.breakCorrespondence() + if self.group: + self.group.breakGroup() + if self.leftBond: + self.leftBond.breakBond() + if self.rightBond: + self.rightBond.breakBond() + while len(self.descriptions): description = self.descriptions[-1] description.breakDescription() - for objekt in self.objectList: - objekt.group = None - if self.group: - self.group.breakGroup() + for o in self.objectList: + o.group = None if self in workspace.structures: workspace.structures.remove(self) if self in workspace.objects: workspace.objects.remove(self) if self in self.string.objects: self.string.objects.remove(self) - if self.correspondence: - self.correspondence.breakCorrespondence() - if self.leftBond: - self.leftBond.breakBond() - if self.rightBond: - self.rightBond.breakBond() def updateInternalStrength(self): slipnet = self.ctx.slipnet