1

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:(NSNotification*)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?

Seb Jachec
  • 3,003
  • 2
  • 30
  • 56
  • Can you post a stack trace? It helps to see exactly what the program is doing when it crashes. – ughoavgfhw Mar 29 '11 at 22:51
  • I'm sorry, but how exactly do I find the "stack trace"? – Seb Jachec Mar 30 '11 at 09:27
  • The stuff you added is the assembly of the current function (which simply returns its first argument). The stack trace is the list of functions that have been called. Since you have the assembly, I am assuming Xcode caught the exception and stopped the program from actually crashing, so you will have to get the stack trace from Xcode's debugger window. In the default view, it is in the top-left corner. It has the function you are currently in at the top and functions that called it below. – ughoavgfhw Mar 30 '11 at 20:51

1 Answers1

0

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).

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498