From: Vadim Zeitlin Date: Sun, 8 Apr 2007 23:25:36 +0000 (+0000) Subject: fix a fatal crash due to using wxHSCROLL presence in m_windowStyle as indicator of... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ccc20afae9a2ed83677e6f46a8472d3b39a087c4?ds=inline fix a fatal crash due to using wxHSCROLL presence in m_windowStyle as indicator of whether we wrap lines or not: this didn't work because wxHSCROLL was temporarily reset in wxWindow::Create() and so we used wxTextWrappedData when we only had created wxTextMultiLineData git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/univ/textctrl.h b/include/wx/univ/textctrl.h index 44cfaa4b46..f126757e99 100644 --- a/include/wx/univ/textctrl.h +++ b/include/wx/univ/textctrl.h @@ -234,9 +234,8 @@ public: virtual bool Enable(bool enable = true); // more readable flag testing methods - bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; } - bool WrapLines() const - { return !IsSingleLine() && !(GetWindowStyle() & wxHSCROLL); } + bool IsPassword() const { return HasFlag(wxTE_PASSWORD); } + bool WrapLines() const { return m_wrapLines; } // only for wxStdTextCtrlInputHandler void RefreshSelection(); @@ -500,7 +499,8 @@ private: // flags bool m_isModified:1, m_isEditable:1, - m_hasCaret:1; + m_hasCaret:1, + m_wrapLines:1; // can't be changed after creation // the rectangle (in client coordinates) to draw text inside wxRect m_rectText; diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index ebb49dcc83..afba680e8d 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -650,6 +650,7 @@ void wxTextCtrl::Init() m_isModified = false; m_isEditable = true; + m_wrapLines = false; m_posLast = m_curPos = @@ -695,9 +696,18 @@ bool wxTextCtrl::Create(wxWindow *parent, // create data object for normal multiline or for controls with line // wrap as needed if ( style & wxHSCROLL ) + { m_data.mdata = new wxTextMultiLineData; - else + } + else // we must wrap lines if we don't have horizontal scrollbar + { + // NB: we can't rely on HasFlag(wxHSCROLL) as the flags can change + // later and even wxWindow::Create() itself temporarily resets + // wxHSCROLL in wxUniv, so remember that we have a wrapped data + // and not just a multi line data in a separate variable + m_wrapLines = true; m_data.wdata = new wxTextWrappedData; + } } else {