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>
|
||||
|
||||
src/NSObjCRuntime.m: Added GSGetInstanceVariable() and
|
||||
* src/NSObjCRuntime.m: Added GSGetInstanceVariable() and
|
||||
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>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Interface for <Class> for GNUStep
|
||||
/* Interface for <NSUserDefaults> for GNUStep
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
||||
|
@ -34,6 +34,7 @@
|
|||
@class NSDictionary;
|
||||
@class NSMutableDictionary;
|
||||
@class NSData;
|
||||
@class NSTimer;
|
||||
|
||||
/* Standard domains */
|
||||
extern NSString* const NSArgumentDomain;
|
||||
|
@ -118,7 +119,7 @@ extern NSString* const NSDateTimeOrdering;
|
|||
NSMutableString *defaultsDatabase;
|
||||
NSMutableString *defaultsDatabaseLockName;
|
||||
NSDistributedLock *defaultsDatabaseLock;
|
||||
BOOL tickingTimer; // for synchronization
|
||||
NSTimer *tickingTimer; // for synchronization
|
||||
}
|
||||
|
||||
/* Getting the Shared Instance */
|
||||
|
|
|
@ -66,6 +66,7 @@ static NSString* GNU_UserDefaultsDatabaseLock = @"GNUstep/.GNUstepUDLock";
|
|||
- (void)__createStandardSearchList;
|
||||
- (NSDictionary *)__createArgumentDictionary;
|
||||
- (void)__changePersistentDomain:(NSString *)domainName;
|
||||
- (void)__timerTicked: (NSTimer*)tim;
|
||||
@end
|
||||
|
||||
@implementation NSUserDefaults: NSObject
|
||||
|
@ -624,7 +625,14 @@ static NSMutableString *processName = 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.
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
|
@ -676,14 +684,23 @@ static NSMutableString *processName = nil;
|
|||
[defaultsDatabaseLock unlock];
|
||||
return NO;
|
||||
}
|
||||
[defaultsDatabaseLock unlock]; // release file lock
|
||||
}
|
||||
else
|
||||
{ // Just update from disk
|
||||
{
|
||||
[defaultsDatabaseLock unlock]; // release file lock
|
||||
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;
|
||||
}
|
||||
|
@ -855,16 +872,6 @@ static NSMutableString *processName = nil;
|
|||
postNotificationName:NSUserDefaultsDidChangeNotification object:nil];
|
||||
}
|
||||
|
||||
if (!tickingTimer)
|
||||
{
|
||||
[NSTimer scheduledTimerWithTimeInterval:30
|
||||
target:self
|
||||
selector:@selector(synchronize)
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
tickingTimer = YES;
|
||||
}
|
||||
|
||||
enumerator = [changedDomains objectEnumerator];
|
||||
while ((obj = [enumerator nextObject]))
|
||||
{
|
||||
|
@ -875,4 +882,11 @@ static NSMutableString *processName = nil;
|
|||
return;
|
||||
}
|
||||
|
||||
- (void) __timerTicked: (NSTimer*)tim
|
||||
{
|
||||
if (tim == tickingTimer)
|
||||
tickingTimer = nil;
|
||||
|
||||
[self synchronize];
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue