mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +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
|
@ -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
|
||||
[persDomains release];
|
||||
persDomains = newDict;
|
||||
{
|
||||
[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