From c77a67962c2f50a872491869fcf1a6c082fdc6c6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Sep 2005 23:27:27 +0000 Subject: [PATCH] use wxIsSameDouble() and wxIsNullDouble() for warning-less double comparison of doubles git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/geometry.h | 10 +++--- include/wx/matrix.h | 21 ++++++------- src/common/dcbase.cpp | 13 ++++---- src/common/geometry.cpp | 4 +-- src/common/image.cpp | 66 ++++++++++++++++++++++++---------------- src/common/matrix.cpp | 67 +++++++++++++++++++---------------------- src/generic/dcpsg.cpp | 21 ++++++++----- src/generic/grid.cpp | 4 ++- src/gtk/dcclient.cpp | 21 ++++++------- src/gtk/statbox.cpp | 2 +- src/gtk/textctrl.cpp | 3 +- src/gtk1/dcclient.cpp | 21 ++++++------- src/gtk1/statbox.cpp | 2 +- src/gtk1/textctrl.cpp | 3 +- 14 files changed, 135 insertions(+), 123 deletions(-) diff --git a/include/wx/geometry.h b/include/wx/geometry.h index d38e7ab210..92c2bcbc0d 100644 --- a/include/wx/geometry.h +++ b/include/wx/geometry.h @@ -449,12 +449,12 @@ inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt) inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const { - return m_x == pt.m_x && m_y == pt.m_y; + return wxIsSameDouble(m_x, pt.m_x) && wxIsSameDouble(m_y, pt.m_y); } inline bool wxPoint2DDouble::operator!=(const wxPoint2DDouble& pt) const { - return m_x != pt.m_x || m_y != pt.m_y; + return !(*this == pt); } inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) @@ -590,9 +590,9 @@ public: { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) && ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); } inline bool IsEmpty() const - { return ( m_width <= 0 || m_height <= 0 ); } + { return m_width <= 0 || m_height <= 0; } inline bool HaveEqualSize( const wxRect2DDouble &rect ) const - { return ( rect.m_width == m_width && rect.m_height == m_height ); } + { return wxIsSameDouble(rect.m_width, m_width) && wxIsSameDouble(rect.m_height, m_height); } inline void Inset( wxDouble x , wxDouble y ) { m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * y; } @@ -628,7 +628,7 @@ public: wxRect2DDouble& operator = (const wxRect2DDouble& rect); inline bool operator == (const wxRect2DDouble& rect) const - { return (m_x==rect.m_x && m_y==rect.m_y && m_width==rect.m_width && m_height==rect.m_height); } + { return wxIsSameDouble(m_x, rect.m_x) && wxIsSameDouble(m_y, rect.m_y) && HaveEqualSize(rect); } inline bool operator != (const wxRect2DDouble& rect) const { return !(*this == rect); } diff --git a/include/wx/matrix.h b/include/wx/matrix.h index 8061667a3a..53e0beb3de 100644 --- a/include/wx/matrix.h +++ b/include/wx/matrix.h @@ -214,15 +214,15 @@ inline double wxTransformMatrix::TransformY(double y) const inline bool wxTransformMatrix::IsIdentity1(void) const { return - (m_matrix[0][0] == 1.0 && - m_matrix[1][1] == 1.0 && - m_matrix[2][2] == 1.0 && - m_matrix[1][0] == 0.0 && - m_matrix[2][0] == 0.0 && - m_matrix[0][1] == 0.0 && - m_matrix[2][1] == 0.0 && - m_matrix[0][2] == 0.0 && - m_matrix[1][2] == 0.0) ; + ( wxIsSameDouble(m_matrix[0][0], 1.0) && + wxIsSameDouble(m_matrix[1][1], 1.0) && + wxIsSameDouble(m_matrix[2][2], 1.0) && + wxIsSameDouble(m_matrix[1][0], 0.0) && + wxIsSameDouble(m_matrix[2][0], 0.0) && + wxIsSameDouble(m_matrix[0][1], 0.0) && + wxIsSameDouble(m_matrix[2][1], 0.0) && + wxIsSameDouble(m_matrix[0][2], 0.0) && + wxIsSameDouble(m_matrix[1][2], 0.0) ); } // Calculates the determinant of a 2 x 2 matrix @@ -231,5 +231,4 @@ inline double wxCalculateDet(double a11, double a21, double a12, double a22) return a11 * a22 - a12 * a21; } -#endif - // _WX_MATRIXH__ +#endif // _WX_MATRIXH__ diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 4d86eb2ca0..4cb7b53482 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -25,6 +25,7 @@ #endif #include "wx/dc.h" +#include "wx/math.h" // bool wxDCBase::sm_cacheing = false; @@ -401,15 +402,14 @@ bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) { int totalWidth = 0; - size_t i, len = text.Length(); + const size_t len = text.Length(); widths.Empty(); widths.Add(0, len); - int w, h; // reset the cache if font or horizontal scale have changed - if (!s_fontWidthCache.m_widths || - (s_fontWidthCache.m_scaleX != m_scaleX) || - (s_fontWidthCache.m_font != GetFont())) + if ( !s_fontWidthCache.m_widths || + !wxIsSameDouble(s_fontWidthCache.m_scaleX, m_scaleX) || + (s_fontWidthCache.m_font != GetFont()) ) { s_fontWidthCache.Reset(); s_fontWidthCache.m_font = GetFont(); @@ -418,7 +418,8 @@ bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) // Calculate the position of each character based on the widths of // the previous characters - for (i=0; i= 0 ) return 90; else return 270; } - if ( m_y == 0 ) + if ( wxIsNullDouble(m_y) ) { if ( m_x >= 0 ) return 0; diff --git a/src/common/image.cpp b/src/common/image.cpp index 43634787ce..d7e07b0dc0 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1751,29 +1751,36 @@ wxString wxImage::GetImageExtWildcard() wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb) { - double hue, saturation, value; - const double red = rgb.red / 255.0, green = rgb.green / 255.0, blue = rgb.blue / 255.0; + // find the min and max intensity (and remember which one was it for the + // latter) double minimumRGB = red; - if (green < minimumRGB) + if ( green < minimumRGB ) minimumRGB = green; - - if (blue < minimumRGB) + if ( blue < minimumRGB ) minimumRGB = blue; + enum { RED, GREEN, BLUE } chMax = RED; double maximumRGB = red; - if (green > maximumRGB) + if ( green > maximumRGB ) + { + chMax = GREEN; maximumRGB = green; - - if (blue > maximumRGB) + } + if ( blue > maximumRGB ) + { + chMax = BLUE; maximumRGB = blue; + } - value = maximumRGB; + const double value = maximumRGB; - if (maximumRGB == minimumRGB) + double hue, saturation; + const double deltaRGB = maximumRGB - minimumRGB; + if ( wxIsNullDouble(deltaRGB) ) { // Gray has no color hue = 0.0; @@ -1781,21 +1788,27 @@ wxImage::HSVValue wxImage::RGBtoHSV(const RGBValue& rgb) } else { - double deltaRGB = maximumRGB - minimumRGB; + switch ( chMax ) + { + case RED: + hue = (green - blue) / deltaRGB; + break; - saturation = deltaRGB / maximumRGB; + case GREEN: + hue = 2.0 + (blue - red) / deltaRGB; + break; - if ( red == maximumRGB ) - hue = (green - blue) / deltaRGB; - else if (green == maximumRGB) - hue = 2.0 + (blue - red) / deltaRGB; - else - hue = 4.0 + (red - green) / deltaRGB; + case BLUE: + hue = 4.0 + (red - green) / deltaRGB; + break; + } + + hue /= 6.0; - hue = hue / 6.0; + if ( hue < 0.0 ) + hue += 1.0; - if (hue < 0.0) - hue = hue + 1.0; + saturation = deltaRGB / maximumRGB; } return HSVValue(hue, saturation, value); @@ -1805,13 +1818,14 @@ wxImage::RGBValue wxImage::HSVtoRGB(const HSVValue& hsv) { double red, green, blue; - if ( hsv.saturation == 0.0 ) + if ( wxIsNullDouble(hsv.saturation) ) { - red = hsv.value; //Grey + // Grey + red = hsv.value; green = hsv.value; - blue = hsv.value; + blue = hsv.value; } - else + else // not grey { double hue = hsv.hue * 6.0; // sector 0 to 5 int i = (int)floor(hue); @@ -1877,7 +1891,7 @@ void wxImage::RotateHue(double angle) wxASSERT (angle >= -1.0 && angle <= 1.0); count = M_IMGDATA->m_width * M_IMGDATA->m_height; - if (count > 0 && angle != 0.0) + if ( count > 0 && !wxIsNullDouble(angle) ) { srcBytePtr = M_IMGDATA->m_data; dstBytePtr = srcBytePtr; diff --git a/src/common/matrix.cpp b/src/common/matrix.cpp index 72a72517e4..724b7a5827 100644 --- a/src/common/matrix.cpp +++ b/src/common/matrix.cpp @@ -81,7 +81,7 @@ bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) const { for (j = 0; j < 3; j++) { - if (m_matrix[i][j] != mat.m_matrix[i][j]) + if ( !wxIsSameDouble(m_matrix[i][j], mat.m_matrix[i][j]) ) return false; } } @@ -129,27 +129,22 @@ bool wxTransformMatrix::Invert(void) // now divide by the determinant double det = m_matrix[0][0] * inverseMatrix[0][0] + m_matrix[0][1] * inverseMatrix[1][0] + m_matrix[0][2] * inverseMatrix[2][0]; - if (det != 0.0) - { - inverseMatrix[0][0] /= det; inverseMatrix[1][0] /= det; inverseMatrix[2][0] /= det; - inverseMatrix[0][1] /= det; inverseMatrix[1][1] /= det; inverseMatrix[2][1] /= det; - inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det; + if ( wxIsNullDouble(det) ) + return false; + + inverseMatrix[0][0] /= det; inverseMatrix[1][0] /= det; inverseMatrix[2][0] /= det; + inverseMatrix[0][1] /= det; inverseMatrix[1][1] /= det; inverseMatrix[2][1] /= det; + inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det; - int i, j; - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) { - for (j = 0; j < 3; j++) - { - m_matrix[i][j] = inverseMatrix[i][j]; - } + m_matrix[i][j] = inverseMatrix[i][j]; } - m_isIdentity = IsIdentity1(); - return true; - } - else - { - return false; } + m_isIdentity = IsIdentity1(); + return true; } // Make into identity matrix @@ -195,8 +190,8 @@ wxTransformMatrix& wxTransformMatrix::Scale(const double &xs, const double &ys, if (m_isIdentity) { - double tx =xc*(1-xs); - double ty =yc*(1-ys); + double tx = xc*(1-xs); + double ty = yc*(1-ys); r00 = xs; r10 = 0; r20 = tx; @@ -204,10 +199,10 @@ wxTransformMatrix& wxTransformMatrix::Scale(const double &xs, const double &ys, r11 = ys; r21 = ty; } - else if (xc!=0 || yc!=0) + else if ( !wxIsNullDouble(xc) || !wxIsNullDouble(yc) ) { - double tx =xc*(1-xs); - double ty =yc*(1-ys); + double tx = xc*(1-xs); + double ty = yc*(1-ys); r00 = xs * m_matrix[0][0]; r10 = xs * m_matrix[1][0]; r20 = xs * m_matrix[2][0] + tx; @@ -320,8 +315,8 @@ wxTransformMatrix& wxTransformMatrix::Rotate(const double °rees, const doubl if (m_isIdentity) { - double tx = x*(1-c)+y*s; - double ty = y*(1-c)-x*s; + double tx = x*(1-c)+y*s; + double ty = y*(1-c)-x*s; r00 = c ; r10 = -s; r20 = tx; @@ -329,10 +324,10 @@ wxTransformMatrix& wxTransformMatrix::Rotate(const double °rees, const doubl r11 = c; r21 = ty; } - else if (x!=0 || y!=0) + else if ( !wxIsNullDouble(x) || !wxIsNullDouble(y) ) { - double tx = x*(1-c)+y*s; - double ty = y*(1-c)-x*s; + double tx = x*(1-c)+y*s; + double ty = y*(1-c)-x*s; r00 = c * m_matrix[0][0] - s * m_matrix[0][1] + tx * m_matrix[0][2]; r10 = c * m_matrix[1][0] - s * m_matrix[1][1] + tx * m_matrix[1][2]; r20 = c * m_matrix[2][0] - s * m_matrix[2][1] + tx;// * m_matrix[2][2]; @@ -404,15 +399,15 @@ bool wxTransformMatrix::InverseTransformPoint(double x, double y, double& tx, do { if (IsIdentity()) { - tx = x; ty = y; return true; + tx = x; + ty = y; + return true; } - double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2]; - if (z == 0.0) - { -// z = 0.0000001; + const double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2]; + if ( wxIsNullDouble(z) ) return false; - } + tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0]; ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1]; return true; @@ -556,7 +551,7 @@ double wxTransformMatrix::Get_scaleX() { double scale_factor; double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); - if (rot_angle != 90 && rot_angle != -90) + if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) ) scale_factor = m_matrix[0][0]/cos((rot_angle/180)*pi); else scale_factor = m_matrix[0][0]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! @@ -572,7 +567,7 @@ double wxTransformMatrix::Get_scaleY() { double scale_factor; double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); - if (rot_angle != 90 && rot_angle != -90) + if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) ) scale_factor = m_matrix[1][1]/cos((rot_angle/180)*pi); else scale_factor = m_matrix[1][1]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 75dd0dc5ae..63d3c4bbab 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -405,9 +405,10 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, alpha1 = 0.0; alpha2 = 360.0; } - else if (radius == 0.0) + else if ( wxIsNullDouble(radius) ) { - alpha1 = alpha2 = 0.0; + alpha1 = + alpha2 = 0.0; } else { @@ -460,12 +461,16 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); - if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360; - if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360; - if (sa<0) sa+=360; - if (ea<0) ea+=360; + if ( sa >= 360 || sa <= -360 ) + sa -= int(sa/360)*360; + if ( ea >= 360 || ea <=- 360 ) + ea -= int(ea/360)*360; + if ( sa < 0 ) + sa += 360; + if ( ea < 0 ) + ea += 360; - if (sa==ea) + if ( wxIsSameDouble(sa, ea) ) { DrawEllipse(x,y,w,h); return; @@ -1247,7 +1252,7 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y ) void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle ) { - if (angle == 0.0) + if ( wxIsNullDouble(angle) ) { DoDrawText(text, x, y); return; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 2ab4374312..4a491aae1d 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -38,6 +38,7 @@ #include "wx/combobox.h" #include "wx/valtext.h" #include "wx/intl.h" + #include "wx/math.h" #endif #include "wx/textfile.h" @@ -1085,7 +1086,8 @@ bool wxGridCellFloatEditor::EndEdit(int row, int col, double value = 0.0; wxString text(Text()->GetValue()); - if ( (text.empty() || text.ToDouble(&value)) && (value != m_valueOld) ) + if ( (text.empty() || text.ToDouble(&value)) && + !wxIsSameDouble(value, m_valueOld) ) { if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT)) grid->GetTable()->SetValueAsDouble(row, col, value); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 353ecd4501..4a1ead4f1f 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -538,10 +538,10 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, radius1 = 0.0; radius2 = 360.0; } - else - if (radius == 0.0) + else if ( wxIsNullDouble(radius) ) { - radius1 = radius2 = 0.0; + radius1 = + radius2 = 0.0; } else { @@ -1606,7 +1606,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) { - if (angle == 0.0) + if ( wxIsNullDouble(angle) ) { DrawText(text, x, y); return; @@ -2366,18 +2366,15 @@ void wxWindowDC::Destroy() void wxWindowDC::ComputeScaleAndOrigin() { - /* CMB: copy scale to see if it changes */ - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; + const wxRealPoint origScale(m_scaleX, m_scaleY); wxDC::ComputeScaleAndOrigin(); - /* CMB: if scale has changed call SetPen to recalulate the line width */ - if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && - (m_pen.Ok())) + // if scale has changed call SetPen to recalulate the line width + if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() ) { - /* this is a bit artificial, but we need to force wxDC to think - the pen has changed */ + // this is a bit artificial, but we need to force wxDC to think the pen + // has changed wxPen pen = m_pen; m_pen = wxNullPen; SetPen( pen ); diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp index 313a7ab44f..1cdcca5073 100644 --- a/src/gtk/statbox.cpp +++ b/src/gtk/statbox.cpp @@ -73,7 +73,7 @@ bool wxStaticBox::Create( wxWindow *parent, else // wxALIGN_LEFT xalign = 0.0; - if ( xalign ) + if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5); return TRUE; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index ea62e18185..a6dfa4b31d 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -14,6 +14,7 @@ #include "wx/utils.h" #include "wx/intl.h" #include "wx/log.h" +#include "wx/math.h" #include "wx/settings.h" #include "wx/panel.h" #include "wx/strconv.h" @@ -1029,7 +1030,7 @@ void wxTextCtrl::WriteText( const wxString &text ) GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) ); // Scroll to cursor, but only if scrollbar thumb is at the very bottom - if ( adj->value == adj->upper - adj->page_size ) + if ( wxIsSameDouble(adj->value, adj->upper - adj->page_size) ) { gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 ); diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 353ecd4501..4a1ead4f1f 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -538,10 +538,10 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, radius1 = 0.0; radius2 = 360.0; } - else - if (radius == 0.0) + else if ( wxIsNullDouble(radius) ) { - radius1 = radius2 = 0.0; + radius1 = + radius2 = 0.0; } else { @@ -1606,7 +1606,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) { - if (angle == 0.0) + if ( wxIsNullDouble(angle) ) { DrawText(text, x, y); return; @@ -2366,18 +2366,15 @@ void wxWindowDC::Destroy() void wxWindowDC::ComputeScaleAndOrigin() { - /* CMB: copy scale to see if it changes */ - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; + const wxRealPoint origScale(m_scaleX, m_scaleY); wxDC::ComputeScaleAndOrigin(); - /* CMB: if scale has changed call SetPen to recalulate the line width */ - if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && - (m_pen.Ok())) + // if scale has changed call SetPen to recalulate the line width + if ( wxRealPoint(m_scaleX, m_scaleY) != origScale && m_pen.Ok() ) { - /* this is a bit artificial, but we need to force wxDC to think - the pen has changed */ + // this is a bit artificial, but we need to force wxDC to think the pen + // has changed wxPen pen = m_pen; m_pen = wxNullPen; SetPen( pen ); diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp index 313a7ab44f..1cdcca5073 100644 --- a/src/gtk1/statbox.cpp +++ b/src/gtk1/statbox.cpp @@ -73,7 +73,7 @@ bool wxStaticBox::Create( wxWindow *parent, else // wxALIGN_LEFT xalign = 0.0; - if ( xalign ) + if ( style & (wxALIGN_RIGHT | wxALIGN_CENTER) ) // left alignment is default gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.5); return TRUE; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index ea62e18185..a6dfa4b31d 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -14,6 +14,7 @@ #include "wx/utils.h" #include "wx/intl.h" #include "wx/log.h" +#include "wx/math.h" #include "wx/settings.h" #include "wx/panel.h" #include "wx/strconv.h" @@ -1029,7 +1030,7 @@ void wxTextCtrl::WriteText( const wxString &text ) GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) ); // Scroll to cursor, but only if scrollbar thumb is at the very bottom - if ( adj->value == adj->upper - adj->page_size ) + if ( wxIsSameDouble(adj->value, adj->upper - adj->page_size) ) { gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text), gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 ); -- 2.47.2