synchronization fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35604 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-09-26 13:59:05 +00:00
parent 5a1bd08a7e
commit bca4db00c9
2 changed files with 20 additions and 14 deletions

View file

@ -1,3 +1,8 @@
2012-09-26 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: Fix error synchronising from changes in
database ... was not sending the notification to say we had updated.
2012-09-25 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GNUmakefile:

View file

@ -1773,7 +1773,7 @@ static BOOL isPlistObject(id o)
NSDate *saved;
BOOL wasLocked;
BOOL result = YES;
BOOL haveNewDomain = NO;
BOOL haveChange = NO;
[_lock lock];
saved = _lastSync;
@ -1808,8 +1808,8 @@ static BOOL isPlistObject(id o)
NSString *domainName;
NSFileManager *mgr;
haveNewDomain = [self _readDefaults];
if (YES == haveNewDomain)
haveChange = [self _readDefaults];
if (YES == haveChange)
{
DESTROY(_dictionaryRep);
}
@ -1841,7 +1841,7 @@ static BOOL isPlistObject(id o)
}
}
if (YES == haveNewDomain)
if (YES == haveChange)
{
updateCache(self);
}
@ -1892,7 +1892,7 @@ static BOOL isPlistObject(id o)
[self _changePersistentDomain: NSGlobalDomain];
}
[_lock unlock];
if (YES == haveNewDomain)
if (YES == haveChange)
{
[[NSNotificationCenter defaultCenter]
postNotificationName: NSUserDefaultsDidChangeNotification
@ -2340,7 +2340,7 @@ static BOOL isLocked = NO;
NSEnumerator *enumerator;
NSString *domainName;
NSFileManager *mgr;
BOOL haveNewDomain = NO;
BOOL haveChange = NO;
mgr = [NSFileManager defaultManager];
@ -2377,7 +2377,7 @@ static BOOL isLocked = NO;
owner: self];
[_persDomains setObject: pd forKey: domainName];
[pd release];
haveNewDomain = YES;
haveChange = YES;
}
if (YES == [_searchList containsObject: domainName])
{
@ -2385,11 +2385,11 @@ static BOOL isLocked = NO;
* synchronize to load the domain contents into memory
* so a lookup will work.
*/
[pd synchronize];
haveChange = [pd synchronize];
}
}
}
return haveNewDomain;
return haveChange;
}
- (BOOL) _readOnly
@ -2470,12 +2470,12 @@ static BOOL isLocked = NO;
- (BOOL) synchronize
{
BOOL wasLocked;
BOOL result;
BOOL wasLocked;
BOOL hadChange = NO; // Have we read a change from disk?
if (NO == [owner _lockDefaultsFile: &wasLocked])
{
result = NO;
hadChange = NO;
wasLocked = NO;
}
else
@ -2488,6 +2488,7 @@ static BOOL isLocked = NO;
if (YES == modified && NO == [owner _readOnly])
{
NSDate *mod;
BOOL result;
mod = [NSDate date];
if (0 == [contents count])
@ -2543,15 +2544,15 @@ static BOOL isLocked = NO;
}
}
}
hadChange = YES;
}
result = YES;
}
if (NO == wasLocked)
{
[owner _unlockDefaultsFile];
}
}
return result;
return hadChange;
}
- (NSDate*) updated