From: Julian Smart <julian@anthemion.co.uk>
Date: Sun, 27 Jan 2013 08:41:37 +0000 (+0000)
Subject: Prevent assertions because of zero image size
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ab6b18606429f24c2ef45250eed453fcf3ce26b6

Prevent assertions because of zero image size


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp
index c794229a87..b2ec6db953 100644
--- a/src/richtext/richtextbuffer.cpp
+++ b/src/richtext/richtextbuffer.cpp
@@ -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