Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#16045 closed defect (fixed)

Passing a wxAutoBufferedPaintDC into a wxGCDC crashes

Reported by: snowleopard2 Owned by: vadz
Priority: normal Milestone: 3.0.1
Component: GUI-all Version: dev-latest
Keywords: wxGCDC Cc:
Blocked By: Blocking:
Patch: no

Description

Run this code inside of any OnPaint() event for a control:

wxAutoBufferedPaintDC pdc(this);
wxGCDC dc(pdc);

And you will get an assert complaining about an invalid bitmap handle. I've been using this code sine 2.9, I'm assuming what I am doing is correct. Basically, I need to wrap the paint DC inside of the wxGCDC so that I can then take advantage of wxGCDC's nicer drawing capabilities.

Attachments (1)

BitmapCrash.png download (44.2 KB) - added by snowleopard2 5 months ago.

Download all attachments as: .zip

Change History (5)

Changed 5 months ago by snowleopard2

comment:1 Changed 5 months ago by snowleopard2

  • Summary changed from Passing a paint DC into a wxGCDC crashes to Passing a wxAutoBufferedPaintDC into a wxGCDC crashes

Also, it is wxAutoBufferedPaintDC specifically that's the problem. If I use a wxPaintDC then it runs fine, but using wxAutoBufferedPaintDC gives the invalid handle assertion.

comment:2 Changed 5 months ago by vadz

  • Milestone set to 3.0.1
  • Owner set to vadz
  • Status changed from new to accepted

Thanks for noticing this, it's a bug in (hairy) wxBitmapRefData initialization code. I'll try to commit a fix soon.

comment:3 Changed 5 months ago by VZ

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

(In [76081]) Fix initializing bitmaps from DIB in wxMSW code.

Don't call wxDIB::CreatePalette() on an invalid (because its handle had been
detached from it) DIB object.

Also add some comments to explain this code a bit better.

Closes #16045.

comment:4 Changed 5 months ago by VZ

(In [76082]) Fix initializing bitmaps from DIB in wxMSW code.

Don't call wxDIB::CreatePalette() on an invalid (because its handle had been
detached from it) DIB object.

Also add some comments to explain this code a bit better.

Closes #16045.

Note: See TracTickets for help on using tickets.