From: Jay Freeman (saurik) Date: Thu, 27 Oct 2011 20:18:39 +0000 (+0000) Subject: Use @synchronized in getTheme. X-Git-Tag: v0.9.3904~28 X-Git-Url: https://git.saurik.com/winterboard.git/commitdiff_plain/7c0f4e8c65645644a666e4a5757fef1ca4e63580 Use @synchronized in getTheme. --- 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; } // }}}