-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
%subclass with protocols crashes in the constructor #9
Comments
I got the precompiled .mm version of the .xm source file, and in the constructor the two protocols are added to the class like this: class_addProtocol(_logos_class$_ungrouped$CCSectionViewController, objc_getProtocol("CCSectionDelegate"));
class_addProtocol(_logos_class$_ungrouped$CCSectionViewController, objc_getProtocol("_SBUIWidgetHost")); I took a look at the output of the two Protocol *widgetHost = objc_getProtocol("_SBUIWidgetHost");
Protocol *sectionDelegate = objc_getProtocol("CCSectionDelegate");
NSLog(@"Protocols: %@ %@", widgetHost, sectionDelegate);
NSLog(@"AAAAAAAAAA 1");
class_addProtocol(_logos_class$_ungrouped$CCSectionViewController, sectionDelegate);
NSLog(@"AAAAAAAAAA 2");
class_addProtocol(_logos_class$_ungrouped$CCSectionViewController, widgetHost);
NSLog(@"AAAAAAAAAA 3"); Output:
The So changing the code to this: Protocol *widgetHost = @protocol(_SBUIWidgetHost);
Protocol *sectionDelegate = @protocol(CCSectionDelegate);
NSLog(@"Protocols: %@ %@", widgetHost, sectionDelegate);
NSLog(@"AAAAAAAAAA 1");
class_addProtocol(_logos_class$_ungrouped$CCSectionViewController, sectionDelegate);
NSLog(@"AAAAAAAAAA 2");
class_addProtocol(_logos_class$_ungrouped$CCSectionViewController, widgetHost);
NSLog(@"AAAAAAAAAA 3"); Outputs this:
So to get rid of this issue, the protocols have to be referred to with Changes that have to be made are: $return .= "class_addProtocol(".$self->variable($class).", \@protocol($_)); "; Tested and I can confirm that it works. I'll fork the repo and open a pull request. |
I'm not sure what the right approach is here. Using |
Yeah. Checking if the protocol returned from |
In CCLoader I have %subclass that implements two protocols, a custom one and one defined in SpringBoardUIServices. That subclass (sometimes) crashes in the constructor function. I'm using the latest theos. Here's the crash log, and the %subclass is also in that project: JonasGessner/CCLoader#12
The text was updated successfully, but these errors were encountered: