From d4b4247b2bb00c42659aabd1dea255ae1e15aade Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 11 Apr 2019 21:07:33 +0200 Subject: [PATCH] textbox.cpp/h: use parameter as ref, ensure empty string on empty line array Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1d97e5f0b8b2b0921ceec5302607c32eb61c93bc Author: Thilo Graf Date: 2019-04-11 (Thu, 11 Apr 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/textbox.cpp | 5 +++-- src/gui/widget/textbox.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index bf812c9ce..1be1919cf 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -707,7 +707,8 @@ void CTextBox::refreshText(void) //calculate xpos if ((m_nMode & CENTER) || (m_nMode & RIGHT)) { - x_center = m_cFrameTextRel.iWidth - m_cFrameTextRel.iX - 2*text_Hborder_width - m_pcFontText->getRenderWidth(m_cLineArray[i], m_utf8_encoded); + std::string tmpline = !m_cLineArray.empty() ? m_cLineArray[i] : ""; + x_center = m_cFrameTextRel.iWidth - m_cFrameTextRel.iX - 2*text_Hborder_width - m_pcFontText->getRenderWidth(tmpline, m_utf8_encoded); if (m_nMode & CENTER) x_center /= 2; if (m_nMode & SCROLL) @@ -947,7 +948,7 @@ void CTextBox::disableBackgroundPaint() enableBackgroundPaint(false); } -void CTextBox::setTextRenderModeFullBG(bool mode) +void CTextBox::setTextRenderModeFullBG(const bool& mode) { m_renderMode = (mode) ? 2 /*Font::FULLBG*/ : 0; } diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index c9b69e2e3..63f06f9da 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -191,7 +191,7 @@ class CTextBox : public sigc::trackable void setTextBorderWidth(int Hborder, int Vborder); void setTextFont(Font* font_text); void setTextMode(const int text_mode){m_nMode = text_mode;}; - void setTextRenderModeFullBG(bool mode); + void setTextRenderModeFullBG(const bool& mode); void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; void setWindowPos(const CBox* position){m_cFrame = *position;}; void setWindowMaxDimensions(const int width, const int height);