开发者

NSStatusItem "kCG..." Errors

For some reason, in the Console I'm getting

: kCGErrorIllegalArgument: CGSUnregisterWindowWithSystemStatusBar: Invalid window

: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.

with (I think) this code ...

- (void)applicationDidResignActive:(NSNotificatio开发者_Python百科n*)aNotification
{
        statusItem = [[NSStatusBar systemStatusBar] 
                       statusItemWithLength:NSVariableStatusItemLength];
        [statusItem setHighlightMode:YES];
        [statusItem setEnabled:YES];

            //Set menubar item's tooltip
        [statusItem setToolTip:@"Nucleus"];
        [statusItem setMenu:theMenu];
            //Set the menubar item's title
        [statusItem setTitle:[NSString stringWithString:@"N"]];

    [statusItem retain];

}

- (void)applicationDidBecomeActive:(NSNotification*)aNotification
{
    [[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
}

I believe this is the stack trace (?) :

0x00007fff8667349b <+0000> push %rbp

0x00007fff8667349c <+0001> mov %rsp,%rbp

0x00007fff8667349f <+0004> mov %edi,%eax

0x00007fff866734a1 <+0006> leaveq

0x00007fff866734a2 <+0007> retq

0x00007fff866734a3 <+0008> nop

Why? How can I fix this?

I'm using Cocoa on Mac?


I'm not sure what's causing the error, but I do notice that you're leaking statusItem every time the application deactivates. Perhaps adding a [statusItem release] after removing it from the statusBar will help (it will definitely fix your leak).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜