From f084d731b08c0abe3d4b35aa01ac3786be4c8163 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 2 Jul 2009 03:54:11 +0000 Subject: [PATCH] Clear undo history when clearing document git-svn-id: http://svg-edit.googlecode.com/svn/trunk@252 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 3 ++- editor/svgcanvas.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index df58c6fc..1e6cfa5e 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -345,8 +345,9 @@ function svg_edit_setup() { } var clickClear = function(){ - if( confirm('Do you want to clear the drawing?') ) { + if( confirm('Do you want to clear the drawing?\nThis will also erase your undo history!') ) { svgCanvas.clear(); + updateContextPanel(); } } diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index f1631622..cfd0568b 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1202,6 +1202,10 @@ function SvgCanvas(c) i++; } } + // clear the undo stack + console.log(undoStack); + resetUndoStack(); + console.log(undoStack); call("cleared"); }; @@ -1438,6 +1442,11 @@ function SvgCanvas(c) } }; + var resetUndoStack = function() { + undoStack = []; + undoStackPointer = 0; + }; + this.getUndoStackSize = function() { return undoStackPointer; } this.getRedoStackSize = function() { return undoStack.length - undoStackPointer; }