[Git][wxwidgets/wxwidgets][master] 4 commits: Avoid computing text extent when result is not needed

2 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Jul 18, 2026, 9:05:37 PM (4 days ago) Jul 18
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 53f9c2bc
    by Paul Cornett at 2026-07-18T14:05:38-07:00
    Avoid computing text extent when result is not needed
    
  • f62f0057
    by Paul Cornett at 2026-07-18T15:16:05-07:00
    Simplify GtkTextBuffer reference handling in wxTextCtrl
    
    Just keep a reference, rather than adding/removing when the buffer is detached/attached.
    
  • 8d6c2601
    by Paul Cornett at 2026-07-18T15:33:51-07:00
    Simplify getting GtkEntry max text length
    
  • 91330f94
    by Scott Talbert at 2026-07-18T17:52:07-07:00
    Fix WebRequest tests to work with go-httpbin 2.24.0
    
    go-httpbin 2.24.0 introduced a change to require relative URLs to begin
    with a slash or dot, so update ours to begin with a slash.
    

4 changed files:

Changes:

  • src/gtk/dc.cpp
    ... ... @@ -101,13 +101,14 @@ void wxGTKCairoDCImpl::DoDrawText(const wxString& text, int x, int y)
    101 101
             return;
    
    102 102
         }
    
    103 103
     
    
    104
    -    int w, h;
    
    105
    -    DoGetTextExtent(text, &w, &h);
    
    104
    +    const bool yInverted = m_signY < 0;
    
    105
    +    int w = 0, h = 0;
    
    106
    +    if (xInverted || yInverted || AreAutomaticBoundingBoxUpdatesEnabled())
    
    107
    +        DoGetTextExtent(text, &w, &h);
    
    106 108
     
    
    107 109
         if ( AreAutomaticBoundingBoxUpdatesEnabled() )
    
    108 110
             CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
    
    109 111
     
    
    110
    -    const bool yInverted = m_signY < 0;
    
    111 112
         if (xInverted || yInverted)
    
    112 113
             m_graphicContext->PushState();
    
    113 114
         if (xInverted)
    

  • src/gtk/textctrl.cpp
    ... ... @@ -722,12 +722,10 @@ wxTextCtrl::~wxTextCtrl()
    722 722
         if (m_text)
    
    723 723
             GTKDisconnect(m_text);
    
    724 724
         if (m_buffer)
    
    725
    +    {
    
    725 726
             GTKDisconnect(m_buffer);
    
    726
    -
    
    727
    -    // this is also done by wxWindowGTK dtor, but has to be done here so our
    
    728
    -    // DoThaw() override is called
    
    729
    -    while (IsFrozen())
    
    730
    -        Thaw();
    
    727
    +        g_object_unref(m_buffer);
    
    728
    +    }
    
    731 729
     
    
    732 730
         if (m_anonymousMarkList)
    
    733 731
             g_slist_free_full(m_anonymousMarkList, g_object_unref);
    
    ... ... @@ -774,8 +772,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
    774 772
             // Create view
    
    775 773
             m_text = gtk_text_view_new_with_buffer(m_buffer);
    
    776 774
             GTKConnectFreezeWidget(m_text);
    
    777
    -        // gtk_text_view_set_buffer adds its own reference
    
    778
    -        g_object_unref(m_buffer);
    
    779 775
             g_signal_handler_disconnect(m_buffer, sig_id);
    
    780 776
     
    
    781 777
             // create "ShowPosition" marker
    
    ... ... @@ -2322,7 +2318,6 @@ void wxTextCtrl::DoFreeze()
    2322 2318
         if ( HasFlag(wxTE_MULTILINE) )
    
    2323 2319
         {
    
    2324 2320
             // removing buffer dramatically speeds up insertion:
    
    2325
    -        g_object_ref(m_buffer);
    
    2326 2321
             GtkTextBuffer* buf_new = gtk_text_buffer_new(nullptr);
    
    2327 2322
             gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), buf_new);
    
    2328 2323
             // gtk_text_view_set_buffer adds its own reference
    
    ... ... @@ -2352,7 +2347,6 @@ void wxTextCtrl::DoThaw()
    2352 2347
             // reattach buffer:
    
    2353 2348
             gulong sig_id = g_signal_connect(m_buffer, "mark_set", G_CALLBACK(mark_set), &m_anonymousMarkList);
    
    2354 2349
             gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer);
    
    2355
    -        g_object_unref(m_buffer);
    
    2356 2350
             g_signal_handler_disconnect(m_buffer, sig_id);
    
    2357 2351
     
    
    2358 2352
             if (m_showPositionDefer)
    

  • src/gtk/textentry.cpp
    ... ... @@ -168,11 +168,7 @@ wx_gtk_insert_text_callback(GtkEditable *editable,
    168 168
     {
    
    169 169
         GtkEntry *entry = GTK_ENTRY (editable);
    
    170 170
     
    
    171
    -#if GTK_CHECK_VERSION(3,0,0) || defined(GSEAL_ENABLE)
    
    172
    -    const int text_max_length = gtk_entry_buffer_get_max_length(gtk_entry_get_buffer(entry));
    
    173
    -#else
    
    174
    -    const int text_max_length = entry->text_max_length;
    
    175
    -#endif
    
    171
    +    const int text_max_length = gtk_entry_get_max_length(entry);
    
    176 172
     
    
    177 173
         bool handled = false;
    
    178 174
     
    

  • tests/net/webrequest.cpp
    ... ... @@ -1148,7 +1148,7 @@ TEST_CASE_METHOD(SyncRequestFixture,
    1148 1148
             return;
    
    1149 1149
         }
    
    1150 1150
     
    
    1151
    -    Create("redirect-to?url=post&status_code=307");
    
    1151
    +    Create("redirect-to?url=/post&status_code=307");
    
    1152 1152
         request.SetData("app=WebRequestRedirect&version=1", "application/x-www-form-urlencoded");
    
    1153 1153
         REQUIRE( Execute() );
    
    1154 1154
         CHECK( response.GetStatus() == 200 );
    
    ... ... @@ -1226,7 +1226,7 @@ TEST_CASE_METHOD(SyncRequestFixture,
    1226 1226
     
    
    1227 1227
         SECTION("Password after redirect")
    
    1228 1228
         {
    
    1229
    -        Create("redirect-to?url=basic-auth/wxtest/wxwidgets");
    
    1229
    +        Create("redirect-to?url=/basic-auth/wxtest/wxwidgets");
    
    1230 1230
             request.UseBasicAuth(wxWebCredentials("wxtest", wxSecretValue("wxwidgets")));
    
    1231 1231
     
    
    1232 1232
             CHECK( Execute() );
    

Reply all
Reply to author
Forward
0 new messages