mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 12:11:54 +00:00
Fix bug where a NSDocument would appear unmodified after saving the
document, undoing a number of changes, and then making an equal number of changes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27219 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fe56e4959d
commit
c476e3fa6d
3 changed files with 36 additions and 4 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSDocument.h:
|
||||||
|
* Source/NSDocument.m (-isDocumentEdited, updateChangeCount:,
|
||||||
|
hasUnautosavedChanges, changeWasDone): Fix bug where a document
|
||||||
|
would appear unmodified after saving the document, undoing a
|
||||||
|
number of changes, and then making an equal number of changes.
|
||||||
|
|
||||||
|
* Source/NSDocument.m (-revertDocumentToSaved:): Reset the undo
|
||||||
|
manager after reverting a document.
|
||||||
|
|
||||||
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
* Source/NSDocument.m (-undo:, -redo:, -validateMenuItem:): Move
|
* Source/NSDocument.m (-undo:, -redo:, -validateMenuItem:): Move
|
||||||
|
|
|
@ -108,7 +108,9 @@ typedef enum _NSSaveOperationType {
|
||||||
struct __docFlags {
|
struct __docFlags {
|
||||||
unsigned int in_close:1;
|
unsigned int in_close:1;
|
||||||
unsigned int has_undo_manager:1;
|
unsigned int has_undo_manager:1;
|
||||||
unsigned int RESERVED:30;
|
unsigned int permanently_modified:1;
|
||||||
|
unsigned int autosave_permanently_modified:1;
|
||||||
|
unsigned int RESERVED:28;
|
||||||
} _doc_flags;
|
} _doc_flags;
|
||||||
void *_reserved1;
|
void *_reserved1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ withContentsOfURL: (NSURL *)url
|
||||||
|
|
||||||
- (BOOL) isDocumentEdited
|
- (BOOL) isDocumentEdited
|
||||||
{
|
{
|
||||||
return _change_count != 0;
|
return _change_count != 0 || _doc_flags.permanently_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateChangeCount: (NSDocumentChangeType)change
|
- (void)updateChangeCount: (NSDocumentChangeType)change
|
||||||
|
@ -398,17 +398,22 @@ withContentsOfURL: (NSURL *)url
|
||||||
|
|
||||||
switch (change)
|
switch (change)
|
||||||
{
|
{
|
||||||
case NSChangeDone: _change_count++;
|
case NSChangeDone: _change_count++;
|
||||||
_autosave_change_count++;
|
_autosave_change_count++;
|
||||||
break;
|
break;
|
||||||
case NSChangeUndone: _change_count--;
|
case NSChangeUndone: _change_count--;
|
||||||
_autosave_change_count--;
|
_autosave_change_count--;
|
||||||
break;
|
break;
|
||||||
case NSChangeReadOtherContents:
|
case NSChangeReadOtherContents:
|
||||||
|
_doc_flags.permanently_modified = 1;
|
||||||
|
break;
|
||||||
case NSChangeCleared: _change_count = 0;
|
case NSChangeCleared: _change_count = 0;
|
||||||
_autosave_change_count = 0;
|
_autosave_change_count = 0;
|
||||||
|
_doc_flags.permanently_modified = 0;
|
||||||
|
_doc_flags.autosave_permanently_modified = 0;
|
||||||
break;
|
break;
|
||||||
case NSChangeAutosaved: _autosave_change_count = 0;
|
case NSChangeAutosaved: _autosave_change_count = 0;
|
||||||
|
_doc_flags.autosave_permanently_modified = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1496,6 +1501,7 @@ originalContentsURL: (NSURL *)orig
|
||||||
error: &error])
|
error: &error])
|
||||||
{
|
{
|
||||||
[self updateChangeCount: NSChangeCleared];
|
[self updateChangeCount: NSChangeCleared];
|
||||||
|
[[self undoManager] removeAllActions];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1652,7 +1658,7 @@ originalContentsURL: (NSURL *)orig
|
||||||
|
|
||||||
- (BOOL)hasUnautosavedChanges
|
- (BOOL)hasUnautosavedChanges
|
||||||
{
|
{
|
||||||
return _autosave_change_count != 0;
|
return _autosave_change_count != 0 || _doc_flags.autosave_permanently_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1690,6 +1696,14 @@ originalContentsURL: (NSURL *)orig
|
||||||
|
|
||||||
- (void) _changeWasDone: (NSNotification *)notification
|
- (void) _changeWasDone: (NSNotification *)notification
|
||||||
{
|
{
|
||||||
|
/* Prevent a document from appearing unmodified after saving the
|
||||||
|
* document, undoing a number of changes, and then making an equal
|
||||||
|
* number of changes. Ditto for autosaved changes.
|
||||||
|
*/
|
||||||
|
if (_change_count < 0)
|
||||||
|
_doc_flags.permanently_modified = 1;
|
||||||
|
if (_autosave_change_count < 0)
|
||||||
|
_doc_flags.autosave_permanently_modified = 1;
|
||||||
[self updateChangeCount: NSChangeDone];
|
[self updateChangeCount: NSChangeDone];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1700,6 +1714,11 @@ originalContentsURL: (NSURL *)orig
|
||||||
|
|
||||||
- (void) _changeWasRedone: (NSNotification *)notification
|
- (void) _changeWasRedone: (NSNotification *)notification
|
||||||
{
|
{
|
||||||
|
/* FIXME
|
||||||
|
* Mac OS X 10.5 uses a new constant NSChangeRedone here, but
|
||||||
|
* old applications are not prepared to handle this constant
|
||||||
|
* and expect NSChangeDone instead.
|
||||||
|
*/
|
||||||
[self updateChangeCount: NSChangeDone];
|
[self updateChangeCount: NSChangeDone];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue