Opened 5 years ago

Closed 4 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-Cocoa Version: stable-latest
Keywords: wxCursor, custom Cc:
Blocked By: Blocking: #11547, #11547, #11547, #11547
Patch: yes

Description

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 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by mikk

comment:1 Changed 4 years ago by vadz

  • Blocking 11547 added

comment:2 Changed 4 years ago by jatupper

  • Blocking

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

Action:

  • 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...")

Result:

  • (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 4 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 4 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 4 years ago by jatupper

  • Blocking

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

Note: See TracTickets for help on using tickets.