Page 1 of 1

[Solved] Crash when trying to access [NSCursor hotpot] and [NSImage size]

Posted: Wed Jun 13, 2018 11:01 pm
by trevordevore
I'm working with [NSCursor] and I'm trying to get hotspot and image size information. I've successfully extracted PNG image data of the cursor and return that to LCS. I am getting crashes when I try to access the [NSCursor hotSpot] and [NSImage size]. No crash report is generated so there isn't much to go on.

Here are the docs for [NSCursor hotSpot]:

https://developer.apple.com/documentati ... guage=objc

I've defined NSPoint as follows:

Code: Select all

public foreign type NSPoint binds to "MCAggregateTypeInfo:ff"
I've defined the foreign handler as follows:

Code: Select all

private foreign handler ObjC_NSCursorHotspot(in pCursor as ObjcId) \
        returns NSPoint \
        binds to "objc:NSCursor.-hotSpot"
I define a variable for NSSize as follows:

Code: Select all

variable tSize as NSSize
Then I put it all together to try and get the hotSpot:

Code: Select all

put ObjC_NSCursorHotspot(tCursor) into tHotspot
(tCursor is valid as that is the variable I use to get the cursor image.)

Here is the line in my code that causes the crash:

https://github.com/trevordevore/lc-maco ... r.lcb#L107

Any ideas?

Re: Crash when trying to access [NSCursor hotpot] and [NSImage size]

Posted: Thu Jun 14, 2018 6:38 pm
by LCMark
@trevordevore: The fields in NSSize and NSPoint are 'platform floats' - I think the code is q? There are float on 32-bit systems and double on 64-bit.

Re: Crash when trying to access [NSCursor hotpot] and [NSImage size]

Posted: Thu Jun 14, 2018 6:40 pm
by LCMark
Or maybe N - seems you've already changed that... CGImageRef is just a pointer type - not an aggregate (it's typedefd as struct*).

Re: Crash when trying to access [NSCursor hotpot] and [NSImage size]

Posted: Thu Jun 14, 2018 6:48 pm
by trevordevore
@LCMark - I forgot to update this thread after Monte helped me last night on Gitter. In the code I have working locally I am using qq. That works in 64-bit. It will crash if the engine is running in 32-bit mode. NN won’t crash in 32-but mode but it won’t return correct values. I added a note about that go a bug report related to 32-bit crashes with FFI.