gpt4 book ai didi

objective-c - 更新到 macOS Mojave 后 [NSWindow orderFrontRegardless] 崩溃

转载 作者:太空狗 更新时间:2023-10-30 03:51:43 26 4
gpt4 key购买 nike

更新到 Mojave 后出现奇怪的崩溃。

没有做任何特别的事情,只是创建一个 NSWindow 并调用 orderFrontRegardless

之前一直运行良好。

1   libsystem_platform.dylib            0x00007fff6610ab5d _sigtramp + 29
2 ??? 0x0000000000000000 0x0 + 0
3 CoreFoundation 0x00007fff39b00bb6 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
4 CoreFoundation 0x00007fff39b00b30 ___CFXRegistrationPost_block_invoke + 63
5 CoreFoundation 0x00007fff39b00a9a _CFXRegistrationPost + 404
6 CoreFoundation 0x00007fff39b08f48 ___CFXNotificationPost_block_invoke + 87
7 CoreFoundation 0x00007fff39a71994 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1642
8 CoreFoundation 0x00007fff39a70d47 _CFXNotificationPost + 732
9 Foundation 0x00007fff3bdab217 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
10 AppKit 0x00007fff3720538b -[NSWindow _setFrameCommon:display:stashSize:] + 3090
11 AppKit 0x00007fff37204766 -[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] + 192
12 AppKit 0x00007fff3720469f -[NSWindow setFrame:display:] + 51
13 AppKit 0x00007fff3727aca9 -[NSWindow _reallyDoOrderWindowAboveOrBelow:relativeTo:findKey:forCounter:force:isModal:] + 1336
14 AppKit 0x00007fff372792a0 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 283
15 AppKit 0x00007fff37a0dce9 -[NSWindow orderFrontRegardless] + 40

代码(这是一个控制台应用程序):

NSWindow *window =    [[NSWindow alloc] initWithContentRect:windowRect
styleMask:windowStyle
backing:NSBackingStoreBuffered
defer:NO];

// Since Snow Leopard, programs without application bundles and Info.plist
// files don't get a menubar and can't be brought to the front unless the
// presentation option is changed
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];

[NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:nil];

最佳答案

如何初始化应用程序?在使用 AppKit 之前,您是否已初始化 NSApplication

像这些步骤在 main.m 中应该是必要的:

@autoreleasepool {
NSApplication* application = NSApplication.sharedApplication;

AppDelegate* delegate = [[AppDelegate alloc] init];
application.delegate = delegate;

[application run];
}

您的委托(delegate)也可能会被释放,因为 NSApp 持有对它的弱引用。

关于objective-c - 更新到 macOS Mojave 后 [NSWindow orderFrontRegardless] 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54754830/

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