Ticket #14916 (closed defect: fixed)

Opened 5 months ago

Last modified 5 months ago

Regression: wxTextMeasure breaks wxGCDC DrawText on wxMSW

Reported by: robind Owned by:
Priority: normal Milestone: 2.9.5
Component: wxMSW Version: 2.9-svn
Keywords: wxTextMeasure wxGCDC GetHDC regression Cc:
Blocked By: Patch: no
Blocking:

Description

The assert in wxTextMeasure::BreginMeasuring is being triggered when trying to draw text on a wxGCDC, either with DrawLabel, or with DrawText when there is a newline in the text. For example:

>>> bmp = wx.EmptyBitmap(100,100)
>>> dc = wx.GCDC(wx.MemoryDC(bmp))
>>> dc
<wx._gdi.GCDC; proxy of <Swig Object of type 'wxGCDC *' at 0x3638110> >
>>> 
>>> dc.DrawText("Hello\nWorld", 5, 5)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\PROJECTS\wx\2.9\wxPython\wx\_gdi.py", line 3823, in DrawText
    return _gdi_.DC_DrawText(*args, **kwargs)
PyAssertionError: C++ assertion "m_hdc" failed at ..\..\src\msw\textmeasure.cpp(65) in wxTextMeasure::BeginMeasuring(): Must not be used with non-native wxDCs

Can this be worked around in wxTextMeasure, or should wxGCDC be able to return a valid handle from GetHDC?

Change History

Changed 5 months ago by VZ

  • status changed from new to closed
  • resolution set to fixed

(In [73292]) Don't call wxTextMeasure::BeginMeasuring() when using non-native wxDC.

This is useless as we don't use wxTextMeasure in this case but just forward to
the wxDC itself, and also results in an assert in wxMSW wxTextMeasure
implementation.

Closes #14916.

Note: See TracTickets for help on using tickets.