[Git][wxwidgets/wxwidgets][master] 5 commits: Fix recently broken min size computation on DPI change

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Jun 23, 2026, 2:11:23 PM (2 days ago) Jun 23
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • aeb11b8b
    by Vadim Zeitlin at 2026-06-23T19:29:16+02:00
    Fix recently broken min size computation on DPI change
    
    Use fitting window size, not client size, which was wrongly used in
    8386a98409 (Restrict the new size after DPI change to the display size,
    2026-06-16).
    
    See #26604.
    
  • bf46cc25
    by Blake-Madden at 2026-06-23T19:30:15+02:00
    Fix typo in wxWebView documentation
    
    Closes #26619.
    
  • b3dea2e6
    by Blake-Madden at 2026-06-23T19:50:44+02:00
    Don't write unnecessary auto render value to SVG output
    
    Also avoid extra spaces in the output if the attribute value is empty
    and so the attribute is not specified.
    
    Closes #26620.
    
  • c77b7ebd
    by dxbjavid at 2026-06-23T20:00:54+02:00
    Fix potentially using uninitialised data in PCX image handler
    
    Reject truncated reads to avoid uninitialised data.
    
    Closes #26624.
    
  • 8262667a
    by Vadim Zeitlin at 2026-06-23T20:01:45+02:00
    Use vector<> instead of manual malloc/free in PCX image handler
    
    No real changes, just use vector<> to avoid having to explicitly call
    free().
    

5 changed files:

Changes:

  • interface/wx/webview.h
    ... ... @@ -821,7 +821,7 @@ public:
    821 821
         @section backend_descriptions Backend Descriptions
    
    822 822
     
    
    823 823
         This class supports using multiple backends, corresponding to different
    
    824
    -    implementations of the same functionality. wxWebViewChrome is available
    
    824
    +    implementations of the same functionality. wxWebViewChromium is available
    
    825 825
         on all three major platforms and each platform also has its own default
    
    826 826
         native backend. Backends are identified by their names, documented in
    
    827 827
         the backend descriptions below.
    

  • src/common/dcsvg.cpp
    ... ... @@ -203,6 +203,8 @@ wxString GetPenPattern(const wxPen& pen)
    203 203
             // these penstyles do not need a pattern.
    
    204 204
             break;
    
    205 205
         }
    
    206
    +    if (!s.empty())
    
    207
    +        s.Prepend(wxS(" "));
    
    206 208
         return s;
    
    207 209
     }
    
    208 210
     
    
    ... ... @@ -291,7 +293,7 @@ wxString GetBrushPattern(const wxBrush& brush)
    291 293
         wxString brushStyle = GetBrushStyleName(brush);
    
    292 294
     
    
    293 295
         if (!brushStyle.empty())
    
    294
    -        s = wxString::Format(wxS("fill=\"url(#%s)\""), brushStyle);
    
    296
    +        s = wxString::Format(wxS(" fill=\"url(#%s)\""), brushStyle);
    
    295 297
     
    
    296 298
         return s;
    
    297 299
     }
    
    ... ... @@ -311,12 +313,10 @@ wxString GetRenderMode(wxSVGShapeRenderingMode style)
    311 313
             mode = wxS("geometricPrecision");
    
    312 314
             break;
    
    313 315
         case wxSVG_SHAPE_RENDERING_AUTO:
    
    314
    -        mode = wxS("auto");
    
    315
    -        break;
    
    316
    +        return wxString();
    
    316 317
         }
    
    317 318
     
    
    318
    -    wxString s = wxString::Format(wxS("shape-rendering=\"%s\""), mode);
    
    319
    -    return s;
    
    319
    +    return wxString::Format(wxS(" shape-rendering=\"%s\""), mode);
    
    320 320
     }
    
    321 321
     
    
    322 322
     wxString CreateBrushFill(const wxBrush& brush, wxSVGShapeRenderingMode mode, wxString& patternName)
    
    ... ... @@ -357,7 +357,7 @@ wxString CreateBrushFill(const wxBrush& brush, wxSVGShapeRenderingMode mode, wxS
    357 357
     
    
    358 358
             s += wxString::Format(wxS("  <pattern id=\"%s\" patternUnits=\"userSpaceOnUse\" width=\"8\" height=\"8\">\n"),
    
    359 359
                 patternName);
    
    360
    -        s += wxString::Format(wxS("    <path stroke=\"%s\" stroke-opacity=\"%s\" %s %s %s/>\n"),
    
    360
    +        s += wxString::Format(wxS("    <path stroke=\"%s\" stroke-opacity=\"%s\" %s %s%s/>\n"),
    
    361 361
                 brushColourStr, NumStr(opacity), brushStrokeStr, pattern, GetRenderMode(mode));
    
    362 362
             s += wxS("  </pattern>\n");
    
    363 363
         }
    
    ... ... @@ -698,8 +698,7 @@ void wxSVGFileDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
    698 698
     {
    
    699 699
         NewGraphicsIfNeeded();
    
    700 700
     
    
    701
    -    wxString s;
    
    702
    -    s = wxString::Format(wxS("  <path d=\"M%d %d L%d %d\" %s %s/>\n"),
    
    701
    +    const wxString s = wxString::Format(wxS("  <path d=\"M%d %d L%d %d\"%s%s/>\n"),
    
    703 702
             x1, y1, x2, y2, GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    704 703
     
    
    705 704
         write(s);
    
    ... ... @@ -713,9 +712,7 @@ void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset
    713 712
         if (n > 1)
    
    714 713
         {
    
    715 714
             NewGraphicsIfNeeded();
    
    716
    -        wxString s;
    
    717
    -
    
    718
    -        s = wxString::Format(wxS("  <path d=\"M%d %d"),
    
    715
    +        wxString s = wxString::Format(wxS("  <path d=\"M%d %d"),
    
    719 716
                 (points[0].x + xoffset), (points[0].y + yoffset));
    
    720 717
     
    
    721 718
             if ( AreAutomaticBoundingBoxUpdatesEnabled() )
    
    ... ... @@ -728,7 +725,7 @@ void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset
    728 725
                     CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
    
    729 726
             }
    
    730 727
     
    
    731
    -        s += wxString::Format(wxS("\" fill=\"none\" %s %s/>\n"),
    
    728
    +        s += wxString::Format(wxS("\" fill=\"none\"%s%s/>\n"),
    
    732 729
                 GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    733 730
     
    
    734 731
             write(s);
    
    ... ... @@ -787,7 +784,7 @@ void wxSVGFileDCImpl::DoDrawSpline(const wxPointList* points)
    787 784
         if ( AreAutomaticBoundingBoxUpdatesEnabled() )
    
    788 785
             CalcBoundingBox(wxRound(p2.m_x), wxRound(p2.m_y));
    
    789 786
     
    
    790
    -    s += wxString::Format("\" fill=\"none\" %s %s/>\n",
    
    787
    +    s += wxString::Format("\" fill=\"none\"%s%s/>\n",
    
    791 788
                               GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    792 789
         write(s);
    
    793 790
     }
    
    ... ... @@ -912,7 +909,7 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
    912 909
     #endif
    
    913 910
     
    
    914 911
                 s = wxString::Format(
    
    915
    -                wxS("  <rect x=\"%s\" y=\"%s\" width=\"%d\" height=\"%d\" %s %s transform=\"%s\"/>\n"),
    
    912
    +                wxS("  <rect x=\"%s\" y=\"%s\" width=\"%d\" height=\"%d\"%s %s transform=\"%s\"/>\n"),
    
    916 913
                     NumStr(xRect), NumStr(yRect), ww, hh,
    
    917 914
                     GetRenderMode(m_writer->GetShapeRenderingMode()), rectStyle, rectTransform);
    
    918 915
     
    
    ... ... @@ -952,9 +949,7 @@ void wxSVGFileDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoo
    952 949
     void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
    
    953 950
     {
    
    954 951
         NewGraphicsIfNeeded();
    
    955
    -    wxString s;
    
    956
    -
    
    957
    -    s = wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%s\" %s %s %s/>\n"),
    
    952
    +    const wxString s = wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%s\"%s%s%s/>\n"),
    
    958 953
             x, y, width, height, NumStr(radius),
    
    959 954
             GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen), GetBrushPattern(m_brush));
    
    960 955
     
    
    ... ... @@ -981,7 +976,7 @@ void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[],
    981 976
                 CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
    
    982 977
         }
    
    983 978
     
    
    984
    -    s += wxString::Format(wxS("\" %s %s %s fill-rule=\"%s\"/>\n"),
    
    979
    +    s += wxString::Format(wxS("\"%s%s%s fill-rule=\"%s\"/>\n"),
    
    985 980
             GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen), GetBrushPattern(m_brush),
    
    986 981
             fillStyle == wxODDEVEN_RULE ? wxS("evenodd") : wxS("nonzero"));
    
    987 982
     
    
    ... ... @@ -1037,8 +1032,7 @@ void wxSVGFileDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord
    1037 1032
         const double rh = height / 2.0;
    
    1038 1033
         const double rw = width / 2.0;
    
    1039 1034
     
    
    1040
    -    wxString s;
    
    1041
    -    s = wxString::Format(wxS("  <ellipse cx=\"%s\" cy=\"%s\" rx=\"%s\" ry=\"%s\" %s %s"),
    
    1035
    +    wxString s = wxString::Format(wxS("  <ellipse cx=\"%s\" cy=\"%s\" rx=\"%s\" ry=\"%s\"%s%s"),
    
    1042 1036
             NumStr(x + rw), NumStr(y + rh), NumStr(rw), NumStr(rh),
    
    1043 1037
             GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    1044 1038
         s += wxS("/>\n");
    
    ... ... @@ -1108,7 +1102,7 @@ void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
    1108 1102
                 x1, y1, NumStr(r1), NumStr(r2), fArc, fSweep, x2, y2, line);
    
    1109 1103
         }
    
    1110 1104
     
    
    1111
    -    s += wxString::Format(wxS("\" %s %s/>\n"),
    
    1105
    +    s += wxString::Format(wxS("\"%s%s/>\n"),
    
    1112 1106
             GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    1113 1107
     
    
    1114 1108
         write(s);
    
    ... ... @@ -1200,7 +1194,7 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord
    1200 1194
             NewGraphicsIfNeeded();
    
    1201 1195
     
    
    1202 1196
             wxString arcFill = arcPath;
    
    1203
    -        arcFill += wxString::Format(wxS(" L%s %s z\" %s %s/>\n"),
    
    1197
    +        arcFill += wxString::Format(wxS(" L%s %s z\"%s%s/>\n"),
    
    1204 1198
                 NumStr(xc), NumStr(yc),
    
    1205 1199
                 GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    1206 1200
             write(arcFill);
    
    ... ... @@ -1209,7 +1203,7 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord
    1209 1203
         wxDCBrushChanger setTransp(*GetOwner(), *wxTRANSPARENT_BRUSH);
    
    1210 1204
         NewGraphicsIfNeeded();
    
    1211 1205
     
    
    1212
    -    wxString arcLine = wxString::Format(wxS("%s\" %s %s/>\n"),
    
    1206
    +    wxString arcLine = wxString::Format(wxS("%s\"%s%s/>\n"),
    
    1213 1207
             arcPath, GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen));
    
    1214 1208
         write(arcLine);
    
    1215 1209
     
    
    ... ... @@ -1247,7 +1241,7 @@ void wxSVGFileDCImpl::DoGradientFillLinear(const wxRect& rect,
    1247 1241
         s += wxS("    </linearGradient>\n");
    
    1248 1242
         s += wxS("  </defs>\n");
    
    1249 1243
     
    
    1250
    -    s += wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"url(#gradient%zu)\" %s %s %s/>\n"),
    
    1244
    +    s += wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"url(#gradient%zu)\"%s%s%s/>\n"),
    
    1251 1245
             rect.x, rect.y, rect.width, rect.height, gradId,
    
    1252 1246
             GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen), GetBrushPattern(m_brush));
    
    1253 1247
     
    
    ... ... @@ -1287,7 +1281,7 @@ void wxSVGFileDCImpl::DoGradientFillConcentric(const wxRect& rect,
    1287 1281
         s += wxS("    </radialGradient>\n");
    
    1288 1282
         s += wxS("  </defs>\n");
    
    1289 1283
     
    
    1290
    -    s += wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"url(#gradient%zu)\" %s %s %s/>\n"),
    
    1284
    +    s += wxString::Format(wxS("  <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"url(#gradient%zu)\"%s%s%s/>\n"),
    
    1291 1285
             rect.x, rect.y, rect.width, rect.height, gradId,
    
    1292 1286
             GetRenderMode(m_writer->GetShapeRenderingMode()), GetPenPattern(m_pen), GetBrushPattern(m_brush));
    
    1293 1287
     
    

  • src/common/imagpcx.cpp
    ... ... @@ -24,6 +24,8 @@
    24 24
     #include "wx/imagpcx.h"
    
    25 25
     #include "wx/wfstream.h"
    
    26 26
     
    
    27
    +#include <vector>
    
    28
    +
    
    27 29
     //-----------------------------------------------------------------------------
    
    28 30
     // wxPCXHandler
    
    29 31
     //-----------------------------------------------------------------------------
    
    ... ... @@ -173,6 +175,8 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
    173 175
         // be at least 5 or higher for 8 bit and 24 bit images).
    
    174 176
     
    
    175 177
         stream.Read(hdr, 128);
    
    178
    +    if (stream.LastRead() != 128)
    
    179
    +        return wxPCX_INVFORMAT;
    
    176 180
     
    
    177 181
         if (hdr[HDR_VERSION] < 5) return wxPCX_VERERR;
    
    178 182
     
    
    ... ... @@ -222,8 +226,8 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
    222 226
         if (!image->IsOk())
    
    223 227
             return wxPCX_MEMERR;
    
    224 228
     
    
    225
    -    if ((p = (unsigned char *) malloc(bytesperline * nplanes)) == nullptr)
    
    226
    -        return wxPCX_MEMERR;
    
    229
    +    std::vector<unsigned char> scanline(bytesperline * nplanes);
    
    230
    +    p = scanline.data();
    
    227 231
     
    
    228 232
         // Now start reading the file, line by line, and store
    
    229 233
         // the data in the format required by wxImage.
    
    ... ... @@ -235,7 +239,11 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
    235 239
             if (encoding)
    
    236 240
                 RLEdecode(p, bytesperline * nplanes, stream);
    
    237 241
             else
    
    242
    +        {
    
    238 243
                 stream.Read(p, bytesperline * nplanes);
    
    244
    +            if (stream.LastRead() != bytesperline * nplanes)
    
    245
    +                return wxPCX_INVFORMAT;
    
    246
    +        }
    
    239 247
     
    
    240 248
             switch (format)
    
    241 249
             {
    
    ... ... @@ -262,8 +270,6 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
    262 270
             }
    
    263 271
         }
    
    264 272
     
    
    265
    -    free(p);
    
    266
    -
    
    267 273
         // For 8 bit images, we read the palette, and then do a second
    
    268 274
         // pass replacing indexes with their RGB values;
    
    269 275
     
    
    ... ... @@ -273,6 +279,8 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
    273 279
                 return wxPCX_INVFORMAT;
    
    274 280
     
    
    275 281
             stream.Read(pal, 768);
    
    282
    +        if (stream.LastRead() != 768)
    
    283
    +            return wxPCX_INVFORMAT;
    
    276 284
     
    
    277 285
             p = image->GetData();
    
    278 286
             for (unsigned long k = height * width; k; k--)
    

  • src/msw/nonownedwnd.cpp
    ... ... @@ -319,7 +319,7 @@ bool wxNonOwnedWindow::HandleDPIChange(const wxSize& newDPI, const wxRect& newRe
    319 319
             wxRect actualNewRect = newRect;
    
    320 320
             if ( wxSizer* sizer = GetSizer() )
    
    321 321
             {
    
    322
    -            const wxSize minSize = sizer->ComputeFittingClientSize(this);
    
    322
    +            const wxSize minSize = sizer->ComputeFittingWindowSize(this);
    
    323 323
                 wxSize diff = minSize - newRect.GetSize();
    
    324 324
     
    
    325 325
                 // We don't want to shrink the window as if the user had increased
    

  • tests/image/image.cpp
    ... ... @@ -1560,6 +1560,33 @@ TEST_CASE_METHOD(ImageHandlersInit, "wxImage::BadPCX", "[image][pcx][error]")
    1560 1560
         REQUIRE( !img.LoadFile(mis, wxBITMAP_TYPE_PCX) );
    
    1561 1561
     }
    
    1562 1562
     
    
    1563
    +TEST_CASE_METHOD(ImageHandlersInit, "wxImage::TruncatedPCXPalette", "[image][pcx][error]")
    
    1564
    +{
    
    1565
    +    // A 1x1 8-bit PCX whose 256-colour palette (which follows the 0x0c
    
    1566
    +    // marker at the very end of the file) is truncated. ReadPCX() used to
    
    1567
    +    // read the fixed 768-byte palette without checking how many bytes were
    
    1568
    +    // actually present, so the unread tail of the buffer stayed
    
    1569
    +    // uninitialised and was then copied into the image data and the
    
    1570
    +    // wxImage palette.
    
    1571
    +    unsigned char data[128 + 2 + 1 + 10] = { 0 };
    
    1572
    +    data[0] = 0x0a;   // manufacturer
    
    1573
    +    data[1] = 0x05;   // version
    
    1574
    +    data[2] = 0x01;   // RLE encoding
    
    1575
    +    data[3] = 0x08;   // bits per pixel
    
    1576
    +    // xmin/ymin/xmax/ymax all zero gives a 1x1 image
    
    1577
    +    data[65] = 0x01;  // one plane
    
    1578
    +    data[66] = 0x01;  // bytes per line
    
    1579
    +    // a single RLE run for one pixel with palette index 255
    
    1580
    +    data[128] = 0xc1;
    
    1581
    +    data[129] = 0xff;
    
    1582
    +    // palette marker followed by only 10 of the expected 768 palette bytes
    
    1583
    +    data[130] = 0x0c;
    
    1584
    +
    
    1585
    +    wxMemoryInputStream mis(data, WXSIZEOF(data));
    
    1586
    +    wxImage img;
    
    1587
    +    REQUIRE( !img.LoadFile(mis, wxBITMAP_TYPE_PCX) );
    
    1588
    +}
    
    1589
    +
    
    1563 1590
     #endif // wxUSE_PCX
    
    1564 1591
     
    
    1565 1592
     TEST_CASE_METHOD(ImageHandlersInit, "wxImage::BadANI", "[image][ani][error]")
    

Reply all
Reply to author
Forward
0 new messages