# HG changeset patch # User laurent # Date 1303217821 -7200 # Node ID 0fa72713501de5fcade725e6153aa39ad93796cf # Parent cbfbd0f7135b7261cd26a11d53c954db2bcd3d93 Modifying data stored in UndoBuffer to get a quicker Undo/Redo diff -r cbfbd0f7135b -r 0fa72713501d PLCControler.py --- a/PLCControler.py Tue Apr 19 14:53:08 2011 +0200 +++ b/PLCControler.py Tue Apr 19 14:57:01 2011 +0200 @@ -194,7 +194,7 @@ # Reset PLCControler internal variables def Reset(self): self.Project = None - self.ProjectBufferEnabled = False + self.ProjectBufferEnabled = True self.ProjectBuffer = None self.ProjectSaved = True self.Buffering = False @@ -2663,7 +2663,7 @@ def CreateProjectBuffer(self, saved): if self.ProjectBufferEnabled: - self.ProjectBuffer = UndoBuffer(self.Copy(self.Project), saved) + self.ProjectBuffer = UndoBuffer(cPickle.dumps(self.Project), saved) else: self.ProjectBuffer = None self.ProjectSaved = saved @@ -2682,20 +2682,19 @@ def BufferProject(self): if self.ProjectBuffer is not None: - self.ProjectBuffer.Buffering(self.Copy(self.Project)) + self.ProjectBuffer.Buffering(cPickle.dumps(self.Project)) else: self.ProjectSaved = False def StartBuffering(self): if self.ProjectBuffer is not None: - self.ProjectBuffer.Buffering(self.Project) self.Buffering = True else: self.ProjectSaved = False def EndBuffering(self): if self.ProjectBuffer is not None and self.Buffering: - self.Project = self.Copy(self.Project) + self.ProjectBuffer.Buffering(cPickle.dumps(self.Project)) self.Buffering = False def MarkProjectAsSaved(self): @@ -2707,21 +2706,24 @@ # Return if project is saved def ProjectIsSaved(self): if self.ProjectBuffer is not None: - return self.ProjectBuffer.IsCurrentSaved() + return self.ProjectBuffer.IsCurrentSaved() and not self.Buffering else: return self.ProjectSaved def LoadPrevious(self): if self.ProjectBuffer is not None: - self.Project = self.Copy(self.ProjectBuffer.Previous()) + if self.Buffering: + self.Project = cPickle.loads(self.ProjectBuffer.Current()) + else: + self.Project = cPickle.loads(self.ProjectBuffer.Previous()) def LoadNext(self): if self.ProjectBuffer is not None: - self.Project = self.Copy(self.ProjectBuffer.Next()) + self.Project = cPickle.loads(self.ProjectBuffer.Next()) def GetBufferState(self): if self.ProjectBuffer is not None: first = self.ProjectBuffer.IsFirst() - last = self.ProjectBuffer.IsLast() + last = self.ProjectBuffer.IsLast() and not self.Buffering return not first, not last return False, False