diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h index b73d192056..1f3d33f973 100644 --- a/include/wx/bmpbndl.h +++ b/include/wx/bmpbndl.h @@ -67,6 +67,9 @@ public: // Notice that the data here is non-const because it can be temporarily // modified while parsing it. static wxBitmapBundle FromSVG(char* data, const wxSize sizeDef); + + // This overload currently makes a copy of the data. + static wxBitmapBundle FromSVG(const char* data, const wxSize sizeDef); #endif // wxHAS_RAW_BITMAP // Create from the resources: all existing versions of the bitmap of the diff --git a/interface/wx/bmpbndl.h b/interface/wx/bmpbndl.h index 4d4b22c893..9808f60b5d 100644 --- a/interface/wx/bmpbndl.h +++ b/interface/wx/bmpbndl.h @@ -195,16 +195,21 @@ public: @param data This data may, or not, have the XML document preamble, i.e. it can start either with @c "" "" "" diff --git a/src/generic/bmpsvg.cpp b/src/generic/bmpsvg.cpp index 912817a37b..f440e5e151 100644 --- a/src/generic/bmpsvg.cpp +++ b/src/generic/bmpsvg.cpp @@ -172,4 +172,12 @@ wxBitmapBundle wxBitmapBundle::FromSVG(char* data, const wxSize sizeDef) return wxBitmapBundle(new wxBitmapBundleImplSVG(svgImage, sizeDef)); } +/* static */ +wxBitmapBundle wxBitmapBundle::FromSVG(const char* data, const wxSize sizeDef) +{ + wxCharBuffer copy(data); + + return FromSVG(copy.data(), sizeDef); +} + #endif // wxHAS_RAW_BITMAP diff --git a/tests/graphics/bmpbundle.cpp b/tests/graphics/bmpbundle.cpp index 3d0f58eedd..701b7e7a20 100644 --- a/tests/graphics/bmpbundle.cpp +++ b/tests/graphics/bmpbundle.cpp @@ -61,8 +61,7 @@ TEST_CASE("BitmapBundle::FromSVG", "[bmpbundle][svg]") "" ; - wxCharBuffer buf(svg_data); - wxBitmapBundle b = wxBitmapBundle::FromSVG(buf.data(), wxSize(20, 20)); + wxBitmapBundle b = wxBitmapBundle::FromSVG(svg_data, wxSize(20, 20)); REQUIRE( b.IsOk() ); CHECK( b.GetDefaultSize() == wxSize(20, 20) ); @@ -72,8 +71,7 @@ TEST_CASE("BitmapBundle::FromSVG", "[bmpbundle][svg]") const char* svg_tag_start = strstr(svg_data, "