Without any changes to my code except building against Qt 4.5 I get the following warning message when I run my application:
除了针对Qt 4.5构建之外,我的代码没有任何更改,当运行我的应用程序时,我收到以下警告消息:
*** _NSAutoreleaseNoPool(): Object 0x50a1b0 of class NSCFNumber autoreleased with
no pool in place - just leaking
I am not using any Objective-C in my code but Qt 4.5 is using a new Cocoa based back end instead of Carbon.
我没有在我的代码中使用任何Objective-C,但Qt 4.5使用的是基于Cocoa的新后端而不是Carbon。
I am not sure how to address and fix this error message. Anyone have a clue?
我不知道如何解决和修复此错误消息。有人有线索吗?
1 个解决方案
#1
Generally, when you see this problem in your code, you bracket the offending code block with NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
before and [pool release];
after. You can set a breakpoint on the _NSAutoreleaseNoPool
function and just look up the stack crawl to see what the offending code is. Keep in mind that -autorelease
is used everywhere in Cocoa, so it might not be a specific call to autorelease in Qt's code that's triggering it.
通常,当您在代码中看到此问题时,您将使用NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]括起违规代码块;之前和[池发布];后。您可以在_NSAutoreleaseNoPool函数上设置断点,只需查找堆栈爬网以查看有问题的代码是什么。请记住,-autorelease在Cocoa中无处不在,所以它可能不是Qt代码中触发它的自动释放的特定调用。
However, since this is Qt's code that's doing this, and, last I checked, Qt/Cocoa was still very much a work in progress, you should probably just submit a bug report with the error and a stack crawl to them, and wait for them to fix it.
但是,由于这是Qt的代码正在执行此操作,并且,最后我检查过,Qt / Cocoa仍然是一个正在进行中的工作,您应该只提交错误报告并向其堆栈爬行,并等待他们来解决它。
#1
Generally, when you see this problem in your code, you bracket the offending code block with NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
before and [pool release];
after. You can set a breakpoint on the _NSAutoreleaseNoPool
function and just look up the stack crawl to see what the offending code is. Keep in mind that -autorelease
is used everywhere in Cocoa, so it might not be a specific call to autorelease in Qt's code that's triggering it.
通常,当您在代码中看到此问题时,您将使用NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]括起违规代码块;之前和[池发布];后。您可以在_NSAutoreleaseNoPool函数上设置断点,只需查找堆栈爬网以查看有问题的代码是什么。请记住,-autorelease在Cocoa中无处不在,所以它可能不是Qt代码中触发它的自动释放的特定调用。
However, since this is Qt's code that's doing this, and, last I checked, Qt/Cocoa was still very much a work in progress, you should probably just submit a bug report with the error and a stack crawl to them, and wait for them to fix it.
但是,由于这是Qt的代码正在执行此操作,并且,最后我检查过,Qt / Cocoa仍然是一个正在进行中的工作,您应该只提交错误报告并向其堆栈爬行,并等待他们来解决它。