]> git.saurik.com Git - wxWidgets.git/commitdiff
Prevent assertions because of zero image size
authorJulian Smart <julian@anthemion.co.uk>
Sun, 27 Jan 2013 08:41:37 +0000 (08:41 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 27 Jan 2013 08:41:37 +0000 (08:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextbuffer.cpp

index c794229a873b3c65fb25f479c6a9a2332395a6bd..b2ec6db953e012666b53366356e0c7ee94b5de17 100644 (file)
@@ -10774,6 +10774,10 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, bool resetCache)
             // Subtract borders
             sz = buffer->GetRichTextCtrl()->GetClientSize();
 
+            // Use a minimum size to stop images becoming very small
+            sz.x = wxMax(sz.x, 100);
+            sz.y = wxMax(sz.y, 100);
+
             wxRect marginRect, borderRect, contentRect, paddingRect, outlineRect;
             marginRect = wxRect(0, 0, sz.x, sz.y);
             buffer->GetBoxRects(dc, buffer, buffer->GetAttributes(), marginRect, borderRect, contentRect, paddingRect, outlineRect);
@@ -10861,6 +10865,10 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, bool resetCache)
             width = (int) (float(m_originalImageSize.GetWidth()) * (float(height)/float(m_originalImageSize.GetHeight())));
     }
 
+    // Prevent the use of zero size
+    width = wxMax(1, width);
+    height = wxMax(1, height);
+
     if (m_imageCache.IsOk() && m_imageCache.GetWidth() == width && m_imageCache.GetHeight() == height)
     {
         // Do nothing, we didn't need to change the image cache