From 7c0f4e8c65645644a666e4a5757fef1ca4e63580 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 27 Oct 2011 20:18:39 +0000 Subject: [PATCH] Use @synchronized in getTheme. --- Library.mm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Library.mm b/Library.mm index 17452bc..7dd009d 100644 --- a/Library.mm +++ b/Library.mm @@ -294,8 +294,13 @@ static NSArray *$useScale$(NSArray *files, bool use = true) { } static NSString *$getTheme$(NSArray *files, NSArray *themes = Themes_) { - if (NSString *path = [Themed_ objectForKey:files]) - return reinterpret_cast(path) == [NSNull null] ? nil : path; + // XXX: this is not reasonable; OMG + id key(files); + + @synchronized (Themed_) { + if (NSString *path = [Themed_ objectForKey:key]) + return reinterpret_cast(path) == [NSNull null] ? nil : path; + } if (Debug_) NSLog(@"WB:Debug: %@", [files description]); @@ -312,7 +317,10 @@ static NSString *$getTheme$(NSArray *files, NSArray *themes = Themes_) { path = nil; set: - [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast(path)) forKey:files]; + @synchronized (Themed_) { + [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast(path)) forKey:key]; + } + return path; } // }}} -- 2.47.2