Author: rfm
Date: Tue Feb 9 15:20:56 2016
New Revision: 39343
URL: http://svn.gna.org/viewcvs/gnustep?rev=39343&view=rev
Log:
Fix by Campbell
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Source/NSUserDefaults.m
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39343&r1=39342&r2=39343&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Tue Feb 9 15:20:56 2016
@@ -1,3 +1,7 @@
+2016-02-09 Larry Campbell <[email protected]>
+
+ * Source/NSUserDefaults.m: Fix for bug #46956
+
2016-02-09 Richard Frith-Macdonald <[email protected]>
* Tools/gdomap.c: Use uint32_t rather than unsigned long ... we are
Modified: libs/base/trunk/Source/NSUserDefaults.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSUserDefaults.m?rev=39343&r1=39342&r2=39343&view=diff
==============================================================================
--- libs/base/trunk/Source/NSUserDefaults.m (original)
+++ libs/base/trunk/Source/NSUserDefaults.m Tue Feb 9 15:20:56 2016
@@ -804,6 +804,21 @@
if (nil == defs)
{
+ const unsigned retryCount = 100;
+ const NSTimeInterval retryInterval = 0.1;
+ unsigned i;
+ for (i = 0; i < retryCount; i++)
+ {
+ [NSThread sleepForTimeInterval:retryInterval];
+ [classLock lock];
+ defs = [sharedDefaults retain];
+ setup = hasSharedDefaults;
+ [classLock unlock];
+ if (YES == setup)
+ {
+ NS_VALRETURN([defs autorelease]);
+ }
+ }
NSLog(@"WARNING - unable to create shared user defaults!\n");
NS_VALRETURN(nil);
}
@@ -1101,6 +1116,7 @@
NSFileManager *mgr = [NSFileManager defaultManager];
NSRange r;
BOOL flag;
+ NSDictionary *argumentsDictionary = nil;
self = [super init];
@@ -1158,8 +1174,12 @@
// Create volatile defaults and add the Argument and the Registration domains
_tempDomains = [[NSMutableDictionaryClass alloc] initWithCapacity: 10];
- [_tempDomains setObject: [self _createArgumentDictionary]
+ argumentsDictionary = [self _createArgumentDictionary];
+ if (nil != argumentsDictionary)
+ {
+ [_tempDomains setObject: argumentsDictionary
forKey: NSArgumentDomain];
+ }
[_tempDomains
setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
forKey: NSRegistrationDomain];
@@ -2164,13 +2184,15 @@
BOOL done;
id key, val;
+ [classLock lock];
+ if (YES == parsingArguments)
+ {
+ [classLock unlock];
+ return nil; // Prevent recursion
+ }
+ parsingArguments = YES;
+ [classLock unlock];
[_lock lock];
- if (YES == parsingArguments)
- {
- [_lock unlock];
- return nil; // Prevent recursion
- }
- parsingArguments = YES;
NS_DURING
{
args = [[NSProcessInfo processInfo] arguments];
@@ -2253,12 +2275,16 @@
}
done = ((key = [enumerator nextObject]) == nil);
}
+ [classLock lock];
parsingArguments = NO;
+ [classLock unlock];
[_lock unlock];
}
NS_HANDLER
{
+ [classLock lock];
parsingArguments = NO;
+ [classLock unlock];
[_lock unlock];
[localException raise];
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs