gpt4 book ai didi

cocoa - NSStatusItem "kCG..."错误

转载 作者:行者123 更新时间:2023-12-03 17:25:44 26 4
gpt4 key购买 nike

出于某种原因,在控制台中我得到

: kCGErrorIllegalArgument: CGSUnregisterWindowWithSystemStatusBar: Invalid window

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

使用(我认为)这段代码...

- (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> mov %rsp,%rbp
0x00007fff8667349f <+0004> mov %edi,%eax
0x00007fff866734a1 <+0006> 离开q
0x00007fff866734a2 <+0007> retq
0x00007fff866734a3 <+0008> nop

为什么?我该如何解决这个问题?

我在 Mac 上使用 Cocoa?

最佳答案

我不确定是什么导致了错误,但我确实注意到每次应用程序停用时都会泄漏 statusItem。也许在从状态栏中删除[statusItem release]后添加它会有所帮助(它肯定会修复您的泄漏)。

关于cocoa - NSStatusItem "kCG..."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5478826/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com