From 0bc02de0129e912e4f040d1f16c582ec843a4924 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Sun, 1 Nov 2015 08:57:06 -0800 Subject: [PATCH] Fixed: method loadCibNamed:(CPString)aName owner:(id)anOwner is broken Previously, the method CPBundle loadCibNamed:(CPString)aName owner:(id)anOwner was broken, it loaded the cib asynchronous instead of synchronous. This was due to bad refactoring of a previous commit refs#c5b250236fa662e3da04e442f4414f95d64d9308 This PR refactor this piece of code and make works the method synchronous as it should. More information here : https://github.com/cappuccino/cappuccino/commit/c5b250236fa662e3da04e442f4414f95d64d9308#commitcomment-14109453 --- AppKit/Cib/CPCibLoading.j | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/AppKit/Cib/CPCibLoading.j b/AppKit/Cib/CPCibLoading.j index fa5bd6956..7c346dd95 100644 --- a/AppKit/Cib/CPCibLoading.j +++ b/AppKit/Cib/CPCibLoading.j @@ -49,7 +49,7 @@ var CPCibOwner = @"CPCibOwner", + (CPCib)loadCibNamed:(CPString)aName owner:(id)anOwner { - return [self loadCibNamed:aName owner:anOwner loadDelegate:nil]; + return [self loadCibFile:[self _cibPathForName:aName withOwner:anOwner] externalNameTable:@{ CPCibOwner: anOwner }]; } - (CPCib)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable @@ -68,14 +68,7 @@ var CPCibOwner = @"CPCibOwner", + (CPCib)loadCibNamed:(CPString)aName owner:(id)anOwner loadDelegate:(id)aDelegate { - if (![aName hasSuffix:@".cib"]) - aName = [aName stringByAppendingString:@".cib"]; - - // Path is based solely on anOwner: - var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle], - path = [bundle _cibPathForResource:aName]; - - return [self loadCibFile:path externalNameTable:@{ CPCibOwner: anOwner } loadDelegate:aDelegate]; + return [self loadCibFile:[self _cibPathForName:aName withOwner:anOwner] externalNameTable:@{ CPCibOwner: anOwner } loadDelegate:aDelegate]; } - (CPCib)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable loadDelegate:(id)aDelegate @@ -101,6 +94,17 @@ var CPCibOwner = @"CPCibOwner", return [self pathForResource:aName]; } ++ (CPString)_cibPathForName:(CPString)aName withOwner:(id)anOwner +{ + if (![aName hasSuffix:@".cib"]) + aName = [aName stringByAppendingString:@".cib"]; + + // Path is based solely on anOwner: + var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle]; + + return [bundle _cibPathForResource:aName]; +} + @end @implementation _CPCibLoadDelegate : CPObject