diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j index 10bb0b4dc..7a8fbb622 100644 --- a/AppKit/CPMenu.j +++ b/AppKit/CPMenu.j @@ -684,13 +684,13 @@ var _CPMenuBarVisible = NO, [_CPMenuWindow poolMenuWindow:aMenuWindow]; - if([aMenuItem isEnabled]) - [CPApp sendAction:[aMenuItem action] to:[aMenuItem target] from:aMenuItem]; - var delegate = [menu delegate]; if ([delegate respondsToSelector:@selector(menuDidClose:)]) [delegate menuDidClose:menu]; + + if([aMenuItem isEnabled]) + [CPApp sendAction:[aMenuItem action] to:[aMenuItem target] from:aMenuItem]; } // Managing Display of State Column diff --git a/AppKit/Cib/_CPCibClassSwapper.j b/AppKit/Cib/_CPCibClassSwapper.j index 6b41bfae0..8e1c133df 100644 --- a/AppKit/Cib/_CPCibClassSwapper.j +++ b/AppKit/Cib/_CPCibClassSwapper.j @@ -31,23 +31,46 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey", { } -+ (id)allocWithCoder:(CPCoder)aCoder ++ (void)allocObjectWithCoder:(CPCoder)aCoder className:(CPString)aClassName { - var theClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperClassNameKey], - theClass = objj_lookUpClass(theClassName); + // FIXME: Also check class classForClassName: + var theClass = [aCoder classForClassName:aClassName]; if (!theClass) { - CPLog.error("Unable to find class " + theClassName + " in cib file."); - - theClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey]; - theClass = objj_lookUpClass(theClassName); - + theClass = objj_lookUpClass(aClassName); + if (!theClass) - [CPException raise:CPInvalidArgumentException reason:@"Unable to find class " + theClassName + " in cib file."]; + return nil; } return [theClass alloc]; } ++ (id)allocWithCoder:(CPCoder)aCoder +{ + if ([aCoder respondsToSelector:@selector(usesOriginalClasses)] && [aCoder usesOriginalClasses]) + { + var theClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey], + object = [self allocObjectWithCoder:aCoder className:theClassName]; + } + else + { + var theClassName = [aCoder decodeObjectForKey:_CPCibClassSwapperClassNameKey], + object = [self allocObjectWithCoder:aCoder className:theClassName]; + + if (!object) + { + CPLog.error("Unable to find class " + theClassName + " in cib file."); + + object = [self allocObjectWithCoder:aCoder className:[aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey]]; + } + } + + if (!object) + [CPException raise:CPInvalidArgumentException reason:@"Unable to find class " + theClassName + " in cib file."]; + + return object; +} + @end diff --git a/Tools/nib2cib/NSClassSwapper.j b/Tools/nib2cib/NSClassSwapper.j index a0e8822fd..f406aa310 100644 --- a/Tools/nib2cib/NSClassSwapper.j +++ b/Tools/nib2cib/NSClassSwapper.j @@ -21,7 +21,7 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey", swapperClass = objj_allocateClassPair(originalClass, swapperClassName); objj_registerClassPair(swapperClass); -try{ + class_addMethod(swapperClass, @selector(initWithCoder:), function(self, _cmd, aCoder) { self = objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder); @@ -36,7 +36,7 @@ try{ return self; }, ""); - }catch(e) { alert("B"); }try{ + class_addMethod(swapperClass, @selector(classForKeyedArchiver), function(self, _cmd) { return [_CPCibClassSwapper class]; @@ -49,7 +49,7 @@ try{ // FIXME: map class name as well? [aCoder encodeObject:aClassName forKey:_CPCibClassSwapperClassNameKey]; [aCoder encodeObject:CP_NSMapClassName(anOriginalClassName) forKey:_CPCibClassSwapperOriginalClassNameKey]; - }, "");}catch(e) { alert("C"); } + }, ""); } return swapperClass; diff --git a/Tools/nib2cib/NSIBObjectData.j b/Tools/nib2cib/NSIBObjectData.j index 11f81287f..a18435793 100644 --- a/Tools/nib2cib/NSIBObjectData.j +++ b/Tools/nib2cib/NSIBObjectData.j @@ -75,9 +75,9 @@ //_accessibilityOidsKeys = [aCoder decodeObjectForKey:@"NSAccessibilityOidsKeys"]; //_accessibilityOidsValues = [aCoder decodeObjectForKey:@"NSAccessibilityOidsValues"]; - _classesKeys = [aCoder decodeObjectForKey:@"NSClassesKeys"];print("d"); - _classesValues = [aCoder decodeObjectForKey:@"NSClassesValues"];print("e"); - + _classesKeys = [aCoder decodeObjectForKey:@"NSClassesKeys"]; + _classesValues = [aCoder decodeObjectForKey:@"NSClassesValues"]; + _connections = [aCoder decodeObjectForKey:@"NSConnections"]; //_fontManager = [aCoder decodeObjectForKey:@"NSFontManager"] retain];