From 9c65d0d2819dad5f5d59f9080abdeffae1f08bdf Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:41:26 +0200 Subject: [PATCH] wxMathPlot: fixed crash when one of its dimensions == 0 --- common/widgets/mathplot.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index 18fe939fc2..6ceb14f3fd 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -167,8 +167,10 @@ void mpInfoLayer::Plot(wxDC & dc, mpWindow & w) #ifdef MATHPLOT_DO_LOGGING // wxLogMessage(_("mpInfoLayer::Plot() screen size has changed from %d x %d to %d x %d"), m_winX, m_winY, scrx, scry); #endif - if (m_winX != 1) m_dim.x = (int) floor((double)(m_dim.x*scrx/m_winX)); - if (m_winY != 1) { + if (m_winX > 1) + m_dim.x = (int) floor((double)(m_dim.x*scrx/m_winX)); + + if (m_winY > 1) { m_dim.y = (int) floor((double)(m_dim.y*scry/m_winY)); UpdateReference(); } @@ -236,8 +238,10 @@ void mpInfoCoords::Plot(wxDC & dc, mpWindow & w) #ifdef MATHPLOT_DO_LOGGING // wxLogMessage(_("mpInfoLayer::Plot() screen size has changed from %d x %d to %d x %d"), m_winX, m_winY, scrx, scry); #endif - if (m_winX != 1) m_dim.x = (int) floor((double)(m_dim.x*scrx/m_winX)); - if (m_winY != 1) { + if (m_winX > 1) + m_dim.x = (int) floor((double)(m_dim.x*scrx/m_winX)); + + if (m_winY > 1) { m_dim.y = (int) floor((double)(m_dim.y*scry/m_winY)); UpdateReference(); } @@ -290,8 +294,10 @@ void mpInfoLegend::Plot(wxDC & dc, mpWindow & w) #ifdef MATHPLOT_DO_LOGGING // wxLogMessage(_("mpInfoLayer::Plot() screen size has changed from %d x %d to %d x %d"), m_winX, m_winY, scrx, scry); #endif - if (m_winX != 1) m_dim.x = (int) floor((double)(m_dim.x*scrx/m_winX)); - if (m_winY != 1) { + if (m_winX > 1) + m_dim.x = (int) floor((double)(m_dim.x*scrx/m_winX)); + + if (m_winY > 1) { m_dim.y = (int) floor((double)(m_dim.y*scry/m_winY)); UpdateReference(); }