NSStatusItem“kCG...”错误
由于某种原因,在控制台中我得到
: kCGErrorIllegalArgument: CGSUnregisterWindowWithSystemStatusBar: 无效窗口
: kCGErrorFailure: 设置一个 断点@CGErrorBreakpoint() 到 在记录错误时捕获错误。
使用(我认为)这段代码...
- (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];
}
我相信这是堆栈跟踪(?):
0x00007fff8667349b <+0000>推送 %rbp
0x00007fff8667349c <+0001>移动%rsp,%rbp
0x00007fff8667349f<+0004>移动%edi,%eax
0x00007fff866734a1<+0006>离开q
0x00007fff866734a2 <+0007> retq
0x00007fff866734a3 <+0008>不
为什么?我该如何解决这个问题?
我在 Mac 上使用 Cocoa 吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定是什么导致了错误,但我确实注意到每次应用程序停用时都会泄漏
statusItem
。也许在从状态栏中删除它之后添加一个[statusItem release]
会有所帮助(它肯定会修复你的泄漏)。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).