NSOpenPanel 在选择文件时崩溃

发布于 2024-12-13 10:59:47 字数 1395 浏览 0 评论 0 原文

我正在使用 NSOpenPanel 来允许用户从他们的 MAC 中选择一个文件。该面板可以正常打开并过滤出正确的文件,但是一旦我单击文件,我的应用程序就会崩溃。

这是我打开面板的代码:

if ([openDlg runModalForDirectory:begin file:filename types:filetypes] == NSOKButton)
{
    NSArray* selected = [openDlg filenames];
    for (int i = 0; i < (int)[selected count]; i++)
    {
        NSString* fileName = [selected objectAtIndex:i];
        string fn = [fileName UTF8String];
        results->Append(Value::NewString(fn));
    }
}

该代码永远不会从 runmodalForDirectory 方法调用中返回。

因此,一旦我选择了一个文件,调试器控制台就会显示以下内容:

Program received signal:  “EXC_BAD_ACCESS”.
warning: Unable to restore previously selected frame.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)

简而言之,我认为此时调用 dlOpen 不安全。

然后我得到这个:

并且调用堆栈如下所示:

Call Stack

递归调用发生前的调用堆栈:

调用堆栈位于名为 WebFullScreenController.mm 的 WebKit 框架文件中,递归调用此方法 setDisableActions:

@implementation CATransaction(SnowLeopardConvenienceFunctions)
+ (void)setDisableActions:(BOOL)flag
{
    [self setValue:[NSNumber numberWithBool:flag] forKey:kCATransactionDisableActions];
}

知道为什么会发生这种情况吗?提前致谢。

I am using NSOpenPanel to allow the user to choose a file from their MAC. The panel opens up fine and filters the correct files out but as soon as I click on a file, my application crashes.

Here is my code to open the panel:

if ([openDlg runModalForDirectory:begin file:filename types:filetypes] == NSOKButton)
{
    NSArray* selected = [openDlg filenames];
    for (int i = 0; i < (int)[selected count]; i++)
    {
        NSString* fileName = [selected objectAtIndex:i];
        string fn = [fileName UTF8String];
        results->Append(Value::NewString(fn));
    }
}

The code never returns from the runmodalForDirectory method call.

So once I select a file the Debugger Console says this:

Program received signal:  “EXC_BAD_ACCESS”.
warning: Unable to restore previously selected frame.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)

Briefly I see not safe to call dlOpen at this time.

and then I get this:

Loading a lot of stack frames

and the call stack looks like this:

Call Stack

Call stack before recursive call happens:

enter image description here

The call stack is in the WebKit framework file called WebFullScreenController.mm recursively calling this method setDisableActions:

@implementation CATransaction(SnowLeopardConvenienceFunctions)
+ (void)setDisableActions:(BOOL)flag
{
    [self setValue:[NSNumber numberWithBool:flag] forKey:kCATransactionDisableActions];
}

Does anybody have any ideas of why this is happening? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不羁少年 2024-12-20 10:59:47

我找到了答案,我们可能可以删除这个问题,事实证明这是我正在使用的 webkit 版本,我必须根据 webkit.org 上发布的错误修复修改 webkit

https://bugs.webkit.org/show_bug.cgi?id=61224

I found the answer, we could probably delete this question, it turned out it was the version of webkit I was using, and I had to modify webkit per this bug fix posted on webkit.org

https://bugs.webkit.org/show_bug.cgi?id=61224

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文