forked from loafle/openapi-generator-original
Fix objc template (#6725)
- A static set needs a static lock or we get multiple locks if the class is inherited - If this fix is not included and SWGObject is accessed from a second thread then we get EXC_BAD_ACCESS error (crash)
This commit is contained in:
parent
4bb5afdefb
commit
195b376f48
@ -8,13 +8,15 @@
|
||||
*/
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError **)err {
|
||||
static NSMutableSet *classNames;
|
||||
static NSObject *lock;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
classNames = [NSMutableSet new];
|
||||
lock = [NSObject new];
|
||||
});
|
||||
|
||||
BOOL initSync;
|
||||
@synchronized([self class])
|
||||
@synchronized(lock)
|
||||
{
|
||||
NSString *className = NSStringFromClass([self class]);
|
||||
initSync = ![classNames containsObject:className];
|
||||
|
@ -8,13 +8,15 @@
|
||||
*/
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError **)err {
|
||||
static NSMutableSet *classNames;
|
||||
static NSObject *lock;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
classNames = [NSMutableSet new];
|
||||
lock = [NSObject new];
|
||||
});
|
||||
|
||||
BOOL initSync;
|
||||
@synchronized([self class])
|
||||
@synchronized(lock)
|
||||
{
|
||||
NSString *className = NSStringFromClass([self class]);
|
||||
initSync = ![classNames containsObject:className];
|
||||
|
@ -8,13 +8,15 @@
|
||||
*/
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict error:(NSError **)err {
|
||||
static NSMutableSet *classNames;
|
||||
static NSObject *lock;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
classNames = [NSMutableSet new];
|
||||
lock = [NSObject new];
|
||||
});
|
||||
|
||||
BOOL initSync;
|
||||
@synchronized([self class])
|
||||
@synchronized(lock)
|
||||
{
|
||||
NSString *className = NSStringFromClass([self class]);
|
||||
initSync = ![classNames containsObject:className];
|
||||
|
Loading…
x
Reference in New Issue
Block a user