From 29cc64eb059f62b91a9feb0110904d9505148c06 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Thu, 11 Oct 2007 08:00:25 +0000 Subject: [PATCH] Apply nsundomanager patch from wolfgang lux git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/stable@25524 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 +++++++++++ Source/NSUndoManager.m | 43 +++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5aafd884..0a12eb58c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-10-11 Wolfgang Lux + + * Source/NSUndoManager: Prevent incorrect posting of notifications + during undo/redo and avoid unnecessary creation of undo groups. + +2007-10-10 Fred Kiefer + + * Source/NSDecimal.m (NSDecimalMultiplyByPowerOf10): Move check of + over/underflow after copy. + Patch by Mark Tracy . + 2007-10-03 Richard Frith-Macdonald * Source/NSData.m: Fix ([-classForCoder:]) to return base class of diff --git a/Source/NSUndoManager.m b/Source/NSUndoManager.m index 214b89897..0306ced55 100644 --- a/Source/NSUndoManager.m +++ b/Source/NSUndoManager.m @@ -162,13 +162,9 @@ @implementation NSUndoManager (Private) - (void) _loop: (id)arg { - if (_groupsByEvent) + if (_groupsByEvent && _group != nil) { - if (_group != nil) - { - [self endUndoGrouping]; - } - [self beginUndoGrouping]; + [self endUndoGrouping]; } _runLoopGroupingPending = NO; } @@ -218,9 +214,10 @@ { RELEASE(parent); - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUndoManagerDidOpenUndoGroupNotification - object: self]; + if (_isUndoing == NO && _isRedoing == NO) + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUndoManagerDidOpenUndoGroupNotification + object: self]; } } @@ -334,9 +331,10 @@ p = RETAIN([g parent]); _group = p; [g orphan]; - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUndoManagerWillCloseUndoGroupNotification - object: self]; + if (_isUndoing == NO && _isRedoing == NO) + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUndoManagerWillCloseUndoGroupNotification + object: self]; if (p == nil) { if (_isUndoing) @@ -882,15 +880,18 @@ if (_modes != newModes) { ASSIGN(_modes, newModes); - [[NSRunLoop currentRunLoop] cancelPerformSelector: @selector(_loop:) - target: self - argument: nil]; - [[NSRunLoop currentRunLoop] performSelector: @selector(_loop:) - target: self - argument: nil - order: NSUndoCloseGroupingRunLoopOrdering - modes: _modes]; - _runLoopGroupingPending = YES; + if (_runLoopGroupingPending) + { + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop cancelPerformSelector: @selector(_loop:) + target: self + argument: nil]; + [runLoop performSelector: @selector(_loop:) + target: self + argument: nil + order: NSUndoCloseGroupingRunLoopOrdering + modes: _modes]; + } } }