[Git][wxwidgets/wxwidgets][master] 2 commits: Add wxNODISCARD to stc.h.in and not only to the generated file

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Jun 5, 2025, 1:08:48 PMJun 5
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 2e6cd534
    by Vadim Zeitlin at 2025-06-05T18:47:54+02:00
    Add wxNODISCARD to stc.h.in and not only to the generated file
    
    This wxNODISCARD was added to stc.h only in 5438f42b4a (Add wxNODISCARD
    to all Clone*() functions that return a pointer, 2025-04-29) and so
    would have been lost when this file is regenerated by gen_iface.py.
    
    Add wxNODISCARD to the manually maintained file too to ensure that this
    doesn't happen.
    
    See #25354.
    
  • e92f57b4
    by Vadim Zeitlin at 2025-06-05T18:50:05+02:00
    Fix fatal assert when using box indicators in wxStyledTextCtrl
    
    This assert, generated from wxEVT_PAINT handler, happened because
    SurfaceImpl class unconditionally casts its wxDC to wxMemoryDC before
    creating wxGraphicsContext from it, but the actual wxDC was a wxPaintDC,
    created in wxStyledTextCtrl::OnPaint(), and not a wxMemoryDC.
    
    Fix this by creating wxBufferedPaintDC, which is a wxMemoryDC, instead.
    
    Note that it is not clear how could this work before as OnPaint()
    created wxPaintDC since always, and SurfaceImpl seems to have always
    needed wxMemoryDC too. It would also be better to avoid casting wxDC to
    wxMemoryDC in the first place, as this forces us to use wxMemoryDC even
    on platforms using double-buffering, i.e. effectively unnecessarily
    triple-buffering drawing here.
    

3 changed files:

Changes:

  • src/stc/stc.cpp
    ... ... @@ -5475,7 +5475,9 @@ void wxStyledTextCtrl::StartStyling(int start, int unused)
    5475 5475
     // Event handlers
    
    5476 5476
     
    
    5477 5477
     void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
    
    5478
    -    wxPaintDC dc(this);
    
    5478
    +    // This _must_ be a wxMemoryDC because the code in SurfaceImpl (see
    
    5479
    +    // PlatWX.cpp) unconditionally casts it to wxMemoryDC currently.
    
    5480
    +    wxBufferedPaintDC dc(this);
    
    5479 5481
         m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
    
    5480 5482
     }
    
    5481 5483
     
    

  • src/stc/stc.cpp.in
    ... ... @@ -724,7 +724,9 @@ void wxStyledTextCtrl::StartStyling(int start, int unused)
    724 724
     // Event handlers
    
    725 725
     
    
    726 726
     void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
    
    727
    -    wxPaintDC dc(this);
    
    727
    +    // This _must_ be a wxMemoryDC because the code in SurfaceImpl (see
    
    728
    +    // PlatWX.cpp) unconditionally casts it to wxMemoryDC currently.
    
    729
    +    wxBufferedPaintDC dc(this);
    
    728 730
         m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
    
    729 731
     }
    
    730 732
     
    

  • src/stc/stc.h.in
    ... ... @@ -718,7 +718,7 @@ public:
    718 718
         bool GetControl() const;
    
    719 719
         bool GetAlt() const;
    
    720 720
     
    
    721
    -    virtual wxEvent* Clone() const override { return new wxStyledTextEvent(*this); }
    
    721
    +    wxNODISCARD virtual wxEvent* Clone() const override { return new wxStyledTextEvent(*this); }
    
    722 722
     
    
    723 723
     #ifndef SWIG
    
    724 724
     private:
    

Reply all
Reply to author
Forward
0 new messages