mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
iBugfix ffor NSUserDefaults
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3579 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
507bceeb41
commit
d4f2f56b87
3 changed files with 40 additions and 19 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,8 +1,14 @@
|
||||||
|
Tue Jan 19 12:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* src/NSUserDefaults.m: Fixed to update periodically from disk and
|
||||||
|
to post notifications if the on-disk copy has changed.
|
||||||
|
* src/include/NSUserDefaults.m: Changed vtimer info for update.
|
||||||
|
|
||||||
Fri Jan 15 10:45:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Fri Jan 15 10:45:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
src/NSObjCRuntime.m: Added GSGetInstanceVariable() and
|
* src/NSObjCRuntime.m: Added GSGetInstanceVariable() and
|
||||||
GSSetInstanceVariable() methods - extensions to gnustep.
|
GSSetInstanceVariable() methods - extensions to gnustep.
|
||||||
src/NSObjCRuntime.h: ditto
|
* src/NSObjCRuntime.h: ditto
|
||||||
|
|
||||||
Tue Jan 12 4:10:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Tue Jan 12 4:10:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Interface for <Class> for GNUStep
|
/* Interface for <NSUserDefaults> for GNUStep
|
||||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
@class NSDictionary;
|
@class NSDictionary;
|
||||||
@class NSMutableDictionary;
|
@class NSMutableDictionary;
|
||||||
@class NSData;
|
@class NSData;
|
||||||
|
@class NSTimer;
|
||||||
|
|
||||||
/* Standard domains */
|
/* Standard domains */
|
||||||
extern NSString* const NSArgumentDomain;
|
extern NSString* const NSArgumentDomain;
|
||||||
|
@ -118,7 +119,7 @@ extern NSString* const NSDateTimeOrdering;
|
||||||
NSMutableString *defaultsDatabase;
|
NSMutableString *defaultsDatabase;
|
||||||
NSMutableString *defaultsDatabaseLockName;
|
NSMutableString *defaultsDatabaseLockName;
|
||||||
NSDistributedLock *defaultsDatabaseLock;
|
NSDistributedLock *defaultsDatabaseLock;
|
||||||
BOOL tickingTimer; // for synchronization
|
NSTimer *tickingTimer; // for synchronization
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Getting the Shared Instance */
|
/* Getting the Shared Instance */
|
||||||
|
|
|
@ -66,6 +66,7 @@ static NSString* GNU_UserDefaultsDatabaseLock = @"GNUstep/.GNUstepUDLock";
|
||||||
- (void)__createStandardSearchList;
|
- (void)__createStandardSearchList;
|
||||||
- (NSDictionary *)__createArgumentDictionary;
|
- (NSDictionary *)__createArgumentDictionary;
|
||||||
- (void)__changePersistentDomain:(NSString *)domainName;
|
- (void)__changePersistentDomain:(NSString *)domainName;
|
||||||
|
- (void)__timerTicked: (NSTimer*)tim;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSUserDefaults: NSObject
|
@implementation NSUserDefaults: NSObject
|
||||||
|
@ -624,7 +625,14 @@ static NSMutableString *processName = nil;
|
||||||
{
|
{
|
||||||
NSMutableDictionary *newDict = nil;
|
NSMutableDictionary *newDict = nil;
|
||||||
|
|
||||||
tickingTimer = NO;
|
if (tickingTimer == nil)
|
||||||
|
{
|
||||||
|
[NSTimer scheduledTimerWithTimeInterval:30
|
||||||
|
target:self
|
||||||
|
selector:@selector(__timerTicked:)
|
||||||
|
userInfo:nil
|
||||||
|
repeats:NO];
|
||||||
|
}
|
||||||
|
|
||||||
// Get file lock - break any lock that is more than five minute old.
|
// Get file lock - break any lock that is more than five minute old.
|
||||||
if ([defaultsDatabaseLock tryLock] == NO)
|
if ([defaultsDatabaseLock tryLock] == NO)
|
||||||
|
@ -676,14 +684,23 @@ static NSMutableString *processName = nil;
|
||||||
[defaultsDatabaseLock unlock];
|
[defaultsDatabaseLock unlock];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
[defaultsDatabaseLock unlock]; // release file lock
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Just update from disk
|
{
|
||||||
[persDomains release];
|
[defaultsDatabaseLock unlock]; // release file lock
|
||||||
persDomains = newDict;
|
if ([persDomains isEqual: newDict] == NO)
|
||||||
|
{
|
||||||
|
[persDomains release];
|
||||||
|
persDomains = newDict;
|
||||||
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
postNotificationName: NSUserDefaultsDidChangeNotification
|
||||||
|
object: nil];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[newDict release];
|
||||||
}
|
}
|
||||||
|
|
||||||
[defaultsDatabaseLock unlock]; // release file lock
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -855,16 +872,6 @@ static NSMutableString *processName = nil;
|
||||||
postNotificationName:NSUserDefaultsDidChangeNotification object:nil];
|
postNotificationName:NSUserDefaultsDidChangeNotification object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tickingTimer)
|
|
||||||
{
|
|
||||||
[NSTimer scheduledTimerWithTimeInterval:30
|
|
||||||
target:self
|
|
||||||
selector:@selector(synchronize)
|
|
||||||
userInfo:nil
|
|
||||||
repeats:NO];
|
|
||||||
tickingTimer = YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
enumerator = [changedDomains objectEnumerator];
|
enumerator = [changedDomains objectEnumerator];
|
||||||
while ((obj = [enumerator nextObject]))
|
while ((obj = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
|
@ -875,4 +882,11 @@ static NSMutableString *processName = nil;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) __timerTicked: (NSTimer*)tim
|
||||||
|
{
|
||||||
|
if (tim == tickingTimer)
|
||||||
|
tickingTimer = nil;
|
||||||
|
|
||||||
|
[self synchronize];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue