[Pyobjc-dev] patch to fix crash on accessing NSProxy and some others
Brought to you by:
ronaldoussoren
|
From: Steven D. M. <sd...@mi...> - 2002-01-22 19:00:15
|
pyobjc crashes when you try to touch some Abstract Proxy classes
like NSProxy. For example, you can't iterate thru the objects
in pyobjc.runtime and print them all without crashing.
Problem is that isKindOfClass: isn't implemented for those
classes as it's intended to be forwarded. But when you're
asking the abstract Class itself, rather than an object of
a subclass, it's not going to get forwarded. (The same goes
for isProxy, which call isKindOfClass: -- they are both
meant to be called on objects, not classes. (Class Objects
are all of type Class.)
Inserting an ISCLASS() test seems to fix this.
I'm not yet sure if there's any other side effects of this patch.
-- Steve Majewski
*** ObjCObject.m.0 Tue Jan 22 12:38:29 2002
--- ObjCObject.m Tue Jan 22 13:37:50 2002
***************
*** 52,58 ****
if (self == NULL)
return NULL;
! if (obj && ([obj isKindOfClass: [NSAutoreleasePool class]] == NO) )
[obj retain];
self->oc_object = obj;
--- 52,59 ----
if (self == NULL)
return NULL;
! if (obj && !ISCLASS(obj) &&
! ([obj isKindOfClass: [NSAutoreleasePool class]] == NO) )
[obj retain];
self->oc_object = obj;
|