petasis / tkdnd

TkDND is an extension that adds native drag & drop capabilities to the Tk toolkit
https://sourceforge.net/projects/tkdnd/
Other
106 stars 24 forks source link

SIGABORT #21

Closed sl1200mk2 closed 2 years ago

sl1200mk2 commented 5 years ago

Hi George, this morning I had a crash as detailed below. tkdnd, tcl and tk are compiled on macOS10.14, targeting macOS10.9 minimum and used on 10.9 system. tcl and tk are compiled as frameworks...

best regards, Nicolas.

Date/Time: 2018-10-26 09:35:49.791 +0200 OS Version: Mac OS X 10.9.5 (13F1911) Report Version: 11 Anonymous UUID: B746FC20-762F-37E0-313B-B945C0730A6E

Sleep/Wake UUID: 5A950CD5-64FA-4086-BF5B-8EDB53B56D25

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information: *** Terminating app due to uncaught exception 'NSImageCacheException', reason: 'Cannot lock focus on image <NSImage 0x7ff8b0359c70 Size={0, 0} Reps=( )>, because it is size zero.' abort() called terminating with uncaught exception of type NSException

Application Specific Backtrace 1: 0 CoreFoundation 0x00007fff8b62c25c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff8ea06e75 objc_exception_throw + 43 2 CoreFoundation 0x00007fff8b62c10c +[NSException raise:format:] + 204 3 AppKit 0x00007fff9130df69 -[NSImage _lockFocusOnRepresentation:rect:context:hints:flipped:] + 334 4 AppKit 0x00007fff9130de09 __51-[NSImage lockFocusWithRect:context:hints:flipped:]_block_invoke + 82 5 AppKit 0x00007fff9130d266 -[NSImage _usingBestRepresentationForRect:context:hints:body:] + 170 6 AppKit 0x00007fff9130d1a7 -[NSImage lockFocusWithRect:context:hints:flipped:] + 207 7 AppKit 0x00007fff91490844 -[NSImage lockFocusFlipped:] + 123 8 libtkdnd2.9.dylib 0x0000000107655653 TkDND_DoDragDropObjCmd + 3395 9 Tcl 0x000000010352ea8b Tcl_GetVersion + 4475 10 Tcl 0x0000000103529906 TclNRRunCallbacks + 166 11 Tcl 0x0000000103529624 Tcl_EvalObjv + 84 12 Tcl 0x000000010352afea Tcl_EvalEx + 3226 13 Tcl 0x000000010352a38c Tcl_EvalEx + 60 14 Tk 0x00000001037537bb Tk_BindEvent + 2667 15 Tk 0x000000010375e174 TkBindEventProc + 772 16 Tk 0x000000010376b70f Tk_HandleEvent + 767 17 Tk 0x000000010376c6f7 Tk_QueueWindowEvent + 903 18 Tcl 0x0000000103676b4c Tcl_ServiceEvent + 204 19 Tcl 0x0000000103676ee2 Tcl_DoOneEvent + 162 20 DLight 0x0000000103349477 main + 551

sl1200mk2 commented 5 years ago

this error raised because I have a binding like that:

proc send_data {event w X Y action namespace} {
    switch $event {
        <<DragInitCmd>> {
            return [list link DND_Text]
        }
        <<DragEndCmd>>  {
            listingReFocus $namespace
        }
    }
}

X11 version of tkdnd does not care..., but the aqua one apparently needs an extra arg. so it's not really an issue...

++

petasis commented 5 years ago

I am not sure I have understood. Is it possible to send a small script that I can use to reproduce the problem?

From what I understood, the problem occurs because you start a drag action, and the binding you have defined in <<DragInitCmd>>, you either return a list of 2 items, or something random (what ever the last command executed has placed as the result).

In the first case, when you return [list link DND_Text], tkdnd will interpret it as "action" and "data". This will happen under both aqua and X11 (and windows), as the code that handles it is in lib/tkdnd.tcl, line 316, which is the "generic" part for all platforms. Is the crash happening when you return the list with the two items?

petasis commented 5 years ago

Ok, after re-formating your second comment, it is obvious that there is only one case, returning a list of two items.

petasis commented 5 years ago

I have an idea on what is happening:

1) You return [list link DND_Text] 2) Tkdnd gets link as action, and tries to get data type and data from DND_Text (as it expects a list of two items) 3) DND_Text is used as the type, and data is the empty string

4) In macdnd.m, line 1100, tkdnd tries to draw this (empty) string, and I think something happens there.

petasis commented 5 years ago

I think I have fixed the issue in the trunk. If the data to be sent is an empty string, it uses a system image, instead of drawing a custom one.

Can you please check with the current git head?

petasis commented 5 years ago

I have also modified demo/basic.tcl, and added a drag source that sends an empty string.

sl1200mk2 commented 5 years ago

Hi George, Thank you for looking into this. I'm away from my computer for 1 week, I will try when I come back.

Best regards, Nicolas

sl1200mk2 commented 2 years ago

outdated