[_NSViewDrawOperation release]:发送到deallocated的消息?

时间:2013-04-26 07:17:59

标签: objective-c macos nsview nscollectionview

我有NSCollectionView由一些图片组成。当鼠标滚动到NSCollectionView时,在某些情况下应用程序崩溃。所以我启用了Zombie ObjectMalloc Stack。当应用程序崩溃时,控制台中会打印-[_NSViewDrawOperation release]: message sent to deallocated instance 0x11ac815e0。我使用malloc_history打印崩溃malloc。

(gdb) info malloc-history 0x11ac815e0
warning: MallocStackLoggingNoCompact not set in target's environment so the malloc history will not be available.
Alloc: Block address: 0x000000011ac815e0 length: 136
Stack - pthread: 0x7fff7981b960 number of frames: 46
    0: 0x7fff8e11136f in malloc_zone_calloc
    1: 0x7fff8e11215d in calloc
    2: 0x7fff8d3c2182 in CGClipStackCreateMutableCopy
    3: 0x7fff8d3c2140 in maybeCopyClipState
    4: 0x7fff8d3c45c3 in CGGStateClipToRect
    5: 0x7fff8d3c4583 in CGContextClipToRect
    6: 0x7fff8d46fca0 in CGContextClipToRects
    7: 0x7fff8eb0cde9 in -[NSView _drawRect:clip:]
    8: 0x7fff8eb3a49b in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
    9: 0x7fff8eb0a8a9 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
   10: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
   11: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
   12: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
   13: 0x7fff8eb051bb in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
   14: 0x7fff8eafdba1 in -[NSView displayIfNeeded]
   15: 0x7fff8eb02d9e in -[NSClipView _immediateScrollToPoint:]
   16: 0x7fff8eb01381 in -[NSClipView scrollToPoint:]
   17: 0x7fff8ebef25b in -[NSScrollView scrollClipView:toPoint:]
   18: 0x7fff8ebeeffe in -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:]
   19: 0x7fff8ebf1fd7 in -[NSClipView _scrollTo:animate:]
   20: 0x7fff8f22c876 in -[NSScrollView _doScroller:hitPart:multiplier:]
   21: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   22: 0x7fff8ebc48ca in -[NSApplication sendAction:to:from:]
   23: 0x7fff8ebc47fe in -[NSControl sendAction:to:]
   24: 0x7fff8f006586 in -[NSScroller sendAction:to:]
   25: 0x7fff8f007a3c in -[NSScroller(NSScrollerPrivate) _scrollByDelta:]
   26: 0x7fff8f22b4c9 in -[NSScrollView _smoothScrollWithEvent:]
   27: 0x7fff8f22a9f8 in -[NSScrollView scrollWheel:]
   28: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   29: 0x7fff8eb938ba in forwardMethod
   30: 0x7fff8f139127 in -[NSView scrollWheel:]
   31: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   32: 0x7fff8eb938ba in forwardMethod
   33: 0x7fff8f139127 in -[NSView scrollWheel:]
   34: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   35: 0x7fff8eb938ba in forwardMethod
   36: 0x7fff8f139127 in -[NSView scrollWheel:]
   37: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   38: 0x7fff8eb938ba in forwardMethod
   39: 0x7fff8f139127 in -[NSView scrollWheel:]
   40: 0x7fff8eb8e0fc in -[NSWindow sendEvent:]
   41: 0x7fff8eb26f74 in -[NSApplication sendEvent:]
   42: 0x7fff8eabda0e in -[NSApplication run]
   43: 0x7fff8ed39eac in NSApplicationMain
   44: 0x100002232 in main at /Users/goham/goham/XcodeApp/BookMark_130424_2112/BookMark/main.m:13
   45: 0x100002204 in start
Dealloc: Block address: 0x000000011ac815e0
Stack - pthread: 0x7fff7981b960 number of frames: 43
    0: 0x7fff8e11175a in free
    1: 0x7fff8d3b39c9 in CGGStateRelease
    2: 0x7fff8d3b3930 in CGGStackRestore
    3: 0x7fff8d3b3909 in CGContextRestoreGState
    4: 0x7fff8eb0d3f8 in -[NSView _drawRect:clip:]
    5: 0x7fff8eb3a49b in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
    6: 0x7fff8eb0a8a9 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    7: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    8: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    9: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
   10: 0x7fff8eb051bb in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
   11: 0x7fff8eafdba1 in -[NSView displayIfNeeded]
   12: 0x7fff8eb02d9e in -[NSClipView _immediateScrollToPoint:]
   13: 0x7fff8eb01381 in -[NSClipView scrollToPoint:]
   14: 0x7fff8ebef25b in -[NSScrollView scrollClipView:toPoint:]
   15: 0x7fff8ebeeffe in -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:]
   16: 0x7fff8ebf1fd7 in -[NSClipView _scrollTo:animate:]
   17: 0x7fff8f22c876 in -[NSScrollView _doScroller:hitPart:multiplier:]
   18: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   19: 0x7fff8ebc48ca in -[NSApplication sendAction:to:from:]
   20: 0x7fff8ebc47fe in -[NSControl sendAction:to:]
   21: 0x7fff8f006586 in -[NSScroller sendAction:to:]
   22: 0x7fff8f007a3c in -[NSScroller(NSScrollerPrivate) _scrollByDelta:]
   23: 0x7fff8f22b4c9 in -[NSScrollView _smoothScrollWithEvent:]
   24: 0x7fff8f22a9f8 in -[NSScrollView scrollWheel:]
   25: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   26: 0x7fff8eb938ba in forwardMethod
   27: 0x7fff8f139127 in -[NSView scrollWheel:]
   28: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   29: 0x7fff8eb938ba in forwardMethod
   30: 0x7fff8f139127 in -[NSView scrollWheel:]
   31: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   32: 0x7fff8eb938ba in forwardMethod
   33: 0x7fff8f139127 in -[NSView scrollWheel:]
   34: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   35: 0x7fff8eb938ba in forwardMethod
   36: 0x7fff8f139127 in -[NSView scrollWheel:]
   37: 0x7fff8eb8e0fc in -[NSWindow sendEvent:]
   38: 0x7fff8eb26f74 in -[NSApplication sendEvent:]
   39: 0x7fff8eabda0e in -[NSApplication run]
   40: 0x7fff8ed39eac in NSApplicationMain
   41: 0x100002232 in main at /Users/goham/goham/XcodeApp/BookMark_130424_2112/BookMark/main.m:13
   42: 0x100002204 in start

Alloc: Block address: 0x000000011ac815e0 length: 96
Stack - pthread: 0x7fff7981b960 number of frames: 43
    0: 0x7fff8e11136f in malloc_zone_calloc
    1: 0x7fff8e11215d in calloc
    2: 0x7fff899040c5 in class_createInstance
    3: 0x7fff910d1ce7 in +[NSObject allocWithZone:]
    4: 0x7fff89904035 in _objc_rootAlloc
    5: 0x7fff8f24347a in -[_NSDisplayOperation queueDrawOperationForView:rect:rectSet:windowRegion:options:]
    6: 0x7fff8eb0af7f in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    7: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    8: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
    9: 0x7fff8eb0bb5e in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
   10: 0x7fff8eb051bb in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
   11: 0x7fff8eafdba1 in -[NSView displayIfNeeded]
   12: 0x7fff8eb02d9e in -[NSClipView _immediateScrollToPoint:]
   13: 0x7fff8eb01381 in -[NSClipView scrollToPoint:]
   14: 0x7fff8ebef25b in -[NSScrollView scrollClipView:toPoint:]
   15: 0x7fff8ebeeffe in -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:]
   16: 0x7fff8ebf1fd7 in -[NSClipView _scrollTo:animate:]
   17: 0x7fff8f22c876 in -[NSScrollView _doScroller:hitPart:multiplier:]
   18: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   19: 0x7fff8ebc48ca in -[NSApplication sendAction:to:from:]
   20: 0x7fff8ebc47fe in -[NSControl sendAction:to:]
   21: 0x7fff8f006586 in -[NSScroller sendAction:to:]
   22: 0x7fff8f007a3c in -[NSScroller(NSScrollerPrivate) _scrollByDelta:]
   23: 0x7fff8f22b4c9 in -[NSScrollView _smoothScrollWithEvent:]
   24: 0x7fff8f22a9f8 in -[NSScrollView scrollWheel:]
   25: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   26: 0x7fff8eb938ba in forwardMethod
   27: 0x7fff8f139127 in -[NSView scrollWheel:]
   28: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   29: 0x7fff8eb938ba in forwardMethod
   30: 0x7fff8f139127 in -[NSView scrollWheel:]
   31: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   32: 0x7fff8eb938ba in forwardMethod
   33: 0x7fff8f139127 in -[NSView scrollWheel:]
   34: 0x7fff9111c70d in -[NSObject performSelector:withObject:]
   35: 0x7fff8eb938ba in forwardMethod
   36: 0x7fff8f139127 in -[NSView scrollWheel:]
   37: 0x7fff8eb8e0fc in -[NSWindow sendEvent:]
   38: 0x7fff8eb26f74 in -[NSApplication sendEvent:]
   39: 0x7fff8eabda0e in -[NSApplication run]
   40: 0x7fff8ed39eac in NSApplicationMain
   41: 0x100002232 in main at /Users/goham/goham/XcodeApp/BookMark_130424_2112/BookMark/main.m:13
   42: 0x100002204 in start

但我仍然不明白这一点。任何人都可以帮助我。谢谢你!

1 个答案:

答案 0 :(得分:0)

NSImageView的{​​{1}}中,我选择了此enter image description here

它导致draw函数在第二个线程中实现。人们遇到这个问题可能会尝试取消选择它,所以draw函数是在主线程中实现的。也许它可以帮到你。