[Git][wxwidgets/wxwidgets][master] Fix wxStaticText label wrapping in wxGTK

4 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
May 30, 2026, 8:13:35 PM (7 days ago) May 30
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • b6278528
    by Vadim Zeitlin at 2026-05-31T01:35:42+02:00
    Fix wxStaticText label wrapping in wxGTK
    
    Both using wxST_WRAP and explicitly calling Wrap() from wxEVT_SIZE
    handler could result in making the visible label completely empty due to
    SetLabel(m_unwrappedLabel) call in wxStaticTextBase::Wrap() not working
    as expected: at least in wxGTK, m_unwrappedLabel was reset by SetLabel()
    before being actually used.
    
    Fix this by passing the already existing local copy of m_unwrappedLabel
    to this function instead.
    
    See https://stackoverflow.com/questions/79948024/wxwidgets-text-wrapping-causes-the-text-to-disappear
    

1 changed file:

Changes:

  • src/common/stattextcmn.cpp
    ... ... @@ -272,7 +272,11 @@ void wxStaticTextBase::Wrap(int width)
    272 272
                                         : m_unwrappedLabel;
    
    273 273
         if ( !m_unwrappedLabel.empty() )
    
    274 274
         {
    
    275
    -        SetLabel( m_unwrappedLabel );
    
    275
    +        // This is tricky: we can't pass m_unwrappedLabel itself to SetLabel()
    
    276
    +        // because it can/will be reset to empty string by this call before it
    
    277
    +        // is used. So pass a copy of it which is not affected by the changes
    
    278
    +        // to m_unwrappedLabel.
    
    279
    +        SetLabel( unwrappedLabel );
    
    276 280
         }
    
    277 281
         wxLabelWrapper wrapper;
    
    278 282
         wrapper.WrapLabel(this, width);
    


View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help Notification message regarding https://gitlab.com/wxwidgets/wxwidgets/-/commit/b627852868459c8722b9b04533d51bdb987bf3a7 at 1780186397

Reply all
Reply to author
Forward
0 new messages