From 8da396c518af4374658d76ce1e49e21997606323 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 19 Feb 2016 11:13:09 +0000 Subject: [PATCH] fixed code that crashes mono compiler. --- src/Perspex.Controls/Utils/UndoRedoHelper.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Perspex.Controls/Utils/UndoRedoHelper.cs b/src/Perspex.Controls/Utils/UndoRedoHelper.cs index 9de2ca9b35..70e5921d8d 100644 --- a/src/Perspex.Controls/Utils/UndoRedoHelper.cs +++ b/src/Perspex.Controls/Utils/UndoRedoHelper.cs @@ -37,7 +37,12 @@ namespace Perspex.Controls.Utils public void Undo() { - _host.UndoRedoState= (_currentNode = _currentNode?.Previous ?? _currentNode).Value; + if (_currentNode != null) + { + _currentNode = _currentNode.Previous; + } + + _host.UndoRedoState = _currentNode?.Value; } public bool IsLastState => _currentNode.Next == null; @@ -62,8 +67,12 @@ namespace Perspex.Controls.Utils } public void Redo() - { - _host.UndoRedoState = (_currentNode = _currentNode?.Next ?? _currentNode).Value; + { + if (_currentNode != null) { + _currentNode = _currentNode.Next; + } + + _host.UndoRedoState = _currentNode?.Value; } public void Snapshot()