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

Moderators: LCMark, LCfraser

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 873
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

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

Post by trevordevore » Wed Jun 13, 2018 11:01 pm

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?
Last edited by trevordevore on Fri Jun 15, 2018 2:34 pm, edited 1 time in total.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 973
Joined: Thu Apr 11, 2013 11:27 am

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

Post by LCMark » Thu Jun 14, 2018 6:38 pm

@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.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 973
Joined: Thu Apr 11, 2013 11:27 am

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

Post by LCMark » Thu Jun 14, 2018 6:40 pm

Or maybe N - seems you've already changed that... CGImageRef is just a pointer type - not an aggregate (it's typedefd as struct*).

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 873
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

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

Post by trevordevore » Thu Jun 14, 2018 6:48 pm

@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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “LiveCode Builder”