IllegalStateException SHKConfiguration #321

Closed
x2on opened this Issue Apr 5, 2012 · 12 comments

Projects

None yet

5 participants

@x2on
x2on commented Apr 5, 2012

I have some crashes with this error message:

*** Terminating app due to uncaught exception 'IllegalStateException', reason: 'SHKConfiguration has already been configured with a delegate.'

I initialize the SHKConfigurator in my AppDelegate:

DefaultSHKConfigurator *configurator = [[MySHKConfigurator alloc] init];
[SHKConfiguration sharedInstanceWithConfigurator:configurator];
@scompt
Contributor
scompt commented Apr 5, 2012

Can you post the entire method where you set the configurator? Do you
set the configurator anywhere else?

On Thu, Apr 5, 2012 at 9:04 AM, Felix Schulze
reply@reply.github.com
wrote:

I have some crashes with this error message:

*** Terminating app due to uncaught exception 'IllegalStateException', reason: 'SHKConfiguration has already been configured with a delegate.'

I initialize the SHKConfigurator in my AppDelegate:

DefaultSHKConfigurator *configurator = [[MySHKConfigurator alloc] init];
[SHKConfiguration sharedInstanceWithConfigurator:configurator];

Reply to this email directly or view it on GitHub:
#321

@x2on
x2on commented Apr 5, 2012

The MySHKConfigurator is a copy from the ShareKitDemoConfigurator with my credentials.

No, i only configure it in the AppDelegate.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [_window addSubview:_navigationController.view];
    [_window makeKeyAndVisible];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{

        ... Init some controller

        DefaultSHKConfigurator *configurator = [[MySHKConfigurator alloc] init];
        [SHKConfiguration sharedInstanceWithConfigurator:configurator];
    });
}
@scompt
Contributor
scompt commented Apr 5, 2012

Can you post the code form your AppDelegate?

On Thu, Apr 5, 2012 at 10:41 AM, Felix Schulze
reply@reply.github.com
wrote:

The MySHKConfigurator is a copy from the ShareKitDemoConfigurator with my credentials.

No, i only configure it in the AppDelegate.


Reply to this email directly or view it on GitHub:
#321 (comment)

@x2on
x2on commented Apr 5, 2012

I updated my post with the code from my AppDelegate.

@scompt
Contributor
scompt commented Apr 5, 2012

Have you tried putting a log message or setting a breakpoint before
you call sharedInstanceWithConfigurator? Maybe you're going through
the code path more than once, which would be an error.

On Thu, Apr 5, 2012 at 11:27 AM, Felix Schulze
reply@reply.github.com
wrote:

I updated my post with the code from my AppDelegate.


Reply to this email directly or view it on GitHub:
#321 (comment)

@x2on
x2on commented Apr 5, 2012

I forgot to say that it works 99% of the time. I personally don't get it to crash but i have some crash reports about that.

I call sharedInstanceWithConfigurator only one time.

@scompt
Contributor
scompt commented Apr 5, 2012

Perhaps pull the code out of the dispatch_after block? Instantiating
the configurator shouldn't take too many cycles.

Alternatively, you could wrap the configuration with dispatch_once.

On Thu, Apr 5, 2012 at 11:42 AM, Felix Schulze
reply@reply.github.com
wrote:

I forgot to say that it works 99% of the time. I personally don't get it to crash but i have some crash reports about that.

I call sharedInstanceWithConfigurator only one time.


Reply to this email directly or view it on GitHub:
#321 (comment)

@x2on
x2on commented Apr 5, 2012

Ok thanks, i will try the dispatch_once solution...

@clozach
Contributor
clozach commented Apr 5, 2012

@x2on Since you can't intentionally reproduce this crash, I'm closing the issue for now. You can reopen it if necessary.

@clozach clozach closed this Apr 5, 2012
@VilemKurz
Contributor

can you explain, what the fix does, and why it fixed the problem? There is not a lot of info about allocWithZone: at all. It seems to be not used too much, see bbum's comment here

@evertoncunha
Contributor

I really don't know. I have two different projects, in one the allocWithZone isn't called, so it works fine, on the other I don't know why but it gets called, and this code fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment