【问题标题】:Need help understanding "kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid Region"需要帮助理解“kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid Region”
【发布时间】:2009-10-20 18:33:53
【问题描述】:

在运行我的应用程序时(它可以进行大量自定义绘图),我收到了这个错误(它发生了很多,没有明显的副作用,但我想了解发生了什么)。

<Error>: kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region
<Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch
         errors as they are logged.

所以我设置了断点并获取了这个堆栈。堆栈帧都不是我的代码,尽管在某些情况下我肯定覆盖了 NSView 的 drawRect。

有没有人以前见过这种情况或对正在发生的事情有所了解?

#0  0x94bee5f2 in CGErrorBreakpoint ()
#1  0x94c831d8 in CGSGlobalErrorv ()
#2  0x94a64b61 in CGSUnionRegionWithRect ()
#3  0x912a2a70 in -[NSRegion addRegion:] ()
#4  0x912a28c1 in -[NSWindow _setNeedsDisplayInRegion:] ()
#5  0x911f3548 in -[NSWindow _absorbDeferredNeedsDisplayRegion] ()
#6  0x911f2113 in -[NSView _sendViewWillDrawInRect:clipRootView:suppressRecursion:] ()
#7  0x91154ee9 in -[NSView displayIfNeeded] ()
#8  0x9111e292 in -[NSWindow displayIfNeeded] ()
#9  0x9114f764 in _handleWindowNeedsDisplay ()
#10 0x9408eb02 in __CFRunLoopDoObservers ()
#11 0x9404b65d in __CFRunLoopRun ()
#12 0x9404ad34 in CFRunLoopRunSpecific ()
#13 0x9404ab61 in CFRunLoopRunInMode ()
#14 0x97984fec in RunCurrentEventLoopInMode ()
#15 0x97984da3 in ReceiveNextEventCommon ()
#16 0x97984c28 in BlockUntilNextEventMatchingListInMode ()
#17 0x91125c95 in _DPSNextEvent ()
#18 0x9112550a in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#19 0x910e769b in -[NSApplication run] ()
#20 0x910df735 in NSApplicationMain ()
#21 0x00002a4f in main (argc=0x1, argv=0xbffff4d4) at 
                  /Users/me/Code/myapp/src/main.m:19

【问题讨论】:

  • 如果您还发布发生错误的代码,那将非常有帮助。
  • 我不知道它发生在哪里。我的代码都没有在堆栈跟踪中。

标签: objective-c cocoa core-animation core-graphics


【解决方案1】:

我最近在控制台中收到了完全相同的消息。
就我而言,我以错误的方式更新进度指示器。
我的进度指示器显示在工作表上,但我没有正确关闭工作表。 当我第二次使用beginSheet 显示 NSSheet 时,总是会弹出错误
您使用的是 NSSheet 吗?
对我来说,它的作用是:

  1. 将didEndSelector 传递给 beginSheet。
  2. 其中的[sheet close]; 选择器
  3. 最后是 [NSApp endSheet] 来关闭工作表

【讨论】:

  • 这听起来很有希望。事实上,我正在更新进度指示器,但没有使用 NSSheet(无论如何都明确表示)。
  • 顺便说一句,您是如何调试问题的?
  • 偶然发现的。起初我怀疑我的自定义绘图代码。但最终它是缺少的 endSheet。我的工作表和进度指示器在应用程序运行中首次显示时工作正常。但它开始为每个后续调用写入“无效区域”消息。
【解决方案2】:

原来我是在请求 NSProgressIndicator 从非主线程显示。一旦我删除它,消息就消失了。

【讨论】:

    猜你喜欢
    • 2013-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 2022-01-15
    • 1970-01-01
    • 2012-09-01
    相关资源
    最近更新 更多