From e483be772603253ace9727591a3f4a24ee5a66f4 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 7 Dec 2013 22:47:37 -0600 Subject: [PATCH] common/gal/stroke_font.cpp was segfaulting in wx 2.8 when drawing multi-line string. --- common/gal/stroke_font.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index 302e8b3293..1566d1820d 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -186,17 +186,18 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double m_gal->SetLineWidth( m_gal->GetLineWidth() * BOLD_FACTOR ); // Split multiline strings into separate ones and draw them line by line - int begin = 0; - int newlinePos = aText.Find( '\n' ); + size_t begin = 0; + size_t newlinePos = aText.find( '\n' ); - while( newlinePos != wxNOT_FOUND ) + while( newlinePos != aText.npos ) { size_t length = newlinePos - begin; + drawSingleLineText( aText.Mid( begin, length ) ); m_gal->Translate( VECTOR2D( 0.0, lineHeight ) ); begin = newlinePos + 1; - newlinePos = aText.find( '\n', begin + 1 ); + newlinePos = aText.find( '\n', begin ); } // Draw the last (or the only one) line