Opened 8 years ago

Closed 8 years ago

#11760 closed defect (fixed)

Using custom cursors in wxOSX-Cocoa crashes the program

Reported by: mikk Owned by:
Priority: normal Milestone:
Component: wxOSX Version: stable-latest
Keywords: wxCursor, custom Cc:
Blocked By: Blocking: #11547, #11547, #11547, #11547
Patch: yes


Using a cursor created from an image, via wxCursor(const wxImage& image), causes the application to crash for wxOSX-Cocoa.

This is due to the fact that wxMacCocoaCreateCursorFromCGImage creates the cursor using an image returned from wxOSXCreateNSImageFromCGImage and then releases it. However, since wxOSXCreateNSImageFromCGImage marks the image for autorelease, wxMacCocoaCreateCursorFromCGImage should not release the image after creating the cursor.

I believe this patch also fixes #11547, though I can't be completely certain as I get a different crash location due to a different use of the cursor.

Attachments (1)

wxOSX-Cocoa-Cursor.patch download (460 bytes) - added by mikk 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by mikk

comment:1 Changed 8 years ago by vadz

  • Blocking 11547 added

comment:2 Changed 8 years ago by jatupper

  • Blocking

(In #11547) Here is a patch that adds a custom cursor to the controls sample.


  • launch the patched controls sample
  • ensure that the wxListBox tab is selected (as it is by default)
  • move the cursor over the top left list box (with "one of my long...")


  • (on my local wxOSX-Carbon) a custom cursor shows up (I think my custom cursor patch(es) are currently outstanding on wxOSX-Carbon)
  • on wxOSX-Cocoa I don't get a crash, but I don't get a custom cursor; in the terminal "* -[NSCFArray isValid]: unrecognized selector sent to instance 0x63de50" shows up (repeatedly when I move the cursor in and out of the list box)

comment:3 Changed 8 years ago by csomor

  • Blocking

(In #11547) shame on my, calling a method ..Create... and having it autorelease the parameter... I'll clean this up

comment:4 Changed 8 years ago by SC

  • Resolution set to fixed
  • Status changed from new to closed

(In [63958]) name change to correctly reflect the autorelease nature of the methods, removing double release, fixes #11547, fixes #11760

comment:5 Changed 8 years ago by jatupper

  • Blocking

(In #11547) Yay! :-) wxOSX-Cocoa seems to have cursors that work!

Note: See TracTickets for help on using tickets.