Drag and Drop from NSTableView fails if more items are written than rows dragged
Originator: | Daniel.Alexander.Alm | ||
Number: | rdar://44135683 | Date Originated: | 09/05/2018 |
Status: | Open | Resolved: | |
Product: | macOS + SDK | AppKit | Product Version: | macOS 10.14 Mojave beta 18A384a |
Classification: | Crash | Reproducible: | Always |
Summary: When writing more pasteboard items to the pasteboard than rows have been dragged in an NSTableView/NSOutlineView/NSCollectionView/NSBrowser, the app crashes. This has also been described in https://forums.developer.apple.com/thread/107824. Steps to Reproduce: 1. Implement `func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool` to write more pasteboard items than rows selected. 2. Drag a row in the table view. Attached is a sample project where dragging the "foo" element in the table instantly triggers a crash. Expected Results: All items are written to the dragging pasteboard and made available to receivers of the drop. Note that there are legitimate reasons for attaching more than one pasteboard item to a row, e.g. when the row represents a set of multiple files. Actual Results: The app crashes with the following error and stack trace: 2018-09-05 14:09:57.175241+0200 TableViewPasteboardCrash[3106:66642] [General] There are 2 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem. 2018-09-05 14:09:57.176486+0200 TableViewPasteboardCrash[3106:66642] [General] ( 0 CoreFoundation 0x00007fff4c1dd43d __exceptionPreprocess + 256 1 libobjc.A.dylib 0x00007fff7802b720 objc_exception_throw + 48 2 CoreFoundation 0x00007fff4c1dd26f +[NSException raise:format:] + 201 3 AppKit 0x00007fff49a03387 -[NSDraggingSession(NSInternal) _initWithPasteboard:image:offset:source:] + 247 4 AppKit 0x00007fff49a02d9f -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1919 5 AppKit 0x00007fff49a02611 -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 134 6 AppKit 0x00007fff49eb9a75 -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 656 7 AppKit 0x00007fff49eb9f09 -[NSTableView __doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 276 8 AppKit 0x00007fff49ebac9e -[NSTableView _performClassicDragOfIndexes:hitRow:event:] + 466 9 AppKit 0x00007fff49a31cf8 -[NSTableView _performDragFromMouseDown:] + 474 10 AppKit 0x00007fff49a2fffc -[NSTableView mouseDown:] + 798 11 AppKit 0x00007fff498b46ef -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5668 12 AppKit 0x00007fff497e872f -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2319 13 AppKit 0x00007fff497e7bd5 -[NSWindow(NSEventRouting) sendEvent:] + 481 ) Version/Build: macOS 10.14 Mojave beta 18A384a
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
The same problem was discovered in an NSTokenFIeld
The same problem was discovered in an NSTokenFIeld.
< NSTokenAttachmentCell: 0x60000217f840 >: There was an exception (There are 3 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem.) raised while processing drag. Ignoring...