From 95b8e8868da0c83b145587773a090ae689133747 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 25 Nov 2014 15:50:26 -0800 Subject: [PATCH] Use @synchronized() to guard Bundles_ (old crash). --- Library.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Library.mm b/Library.mm index 0e69b91..0479b3e 100644 --- a/Library.mm +++ b/Library.mm @@ -434,7 +434,11 @@ static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") { if (path == nil || [path length] == 0 || [path isEqualToString:@"/"]) return nil; - NSBundle *bundle([Bundles_ objectForKey:path]); + NSBundle *bundle; + @synchronized (Bundles_) { + bundle = [Bundles_ objectForKey:path]; + } + if (reinterpret_cast(bundle) == [NSNull null]) return nil; else if (bundle == nil) { @@ -444,7 +448,10 @@ static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") { bundle = [NSBundle wb$bundleWithFile:path]; if (Debug_) NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle); - [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast(bundle)) forKey:path]; + + @synchronized (Bundles_) { + [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast(bundle)) forKey:path]; + } } return bundle; -- 2.45.2