]> git.saurik.com Git - wxWidgets.git/commitdiff
Speeded up image saving to XML (WriteHex).
authorJulian Smart <julian@anthemion.co.uk>
Thu, 24 Mar 2011 10:59:47 +0000 (10:59 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 24 Mar 2011 10:59:47 +0000 (10:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextbuffer.cpp

index 932a824ed790b580068ec9afb8086f30ffdbc2ed..ce0f18c0041d0373468b11b8e1d8fcaa8143a905 100644 (file)
@@ -10417,8 +10417,13 @@ bool wxRichTextImageBlock::Load(wxImage& image)
 // Write data in hex to a stream
 bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream)
 {
-    const int bufSize = 512;
-    char buf[bufSize+1];
+    if (m_dataSize == 0)
+        return true;
+
+    int bufSize = 100000;
+    if (int(m_dataSize+1) < bufSize)
+        bufSize = m_dataSize+1;
+    char* buf = new char[bufSize+1];
 
     int left = m_dataSize;
     int n, i, j;
@@ -10444,6 +10449,7 @@ bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream)
         buf[n] = 0;
         stream.Write((const char*) buf, n);
     }
+    delete[] buf;
     return true;
 }