mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-09 12:17:13 +00:00
Made class swapping more robust.
Reviewed by me.
This commit is contained in:
+3
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user