diff -uNrBb -x setup.h wxWidgets-trunk\include/wx/msw/textctrl.h wxWidgets-work\include/wx/msw/textctrl.h
old
|
new
|
|
285 | 285 | int m_isInkEdit; |
286 | 286 | #endif |
287 | 287 | |
| 288 | // store the expected length of the whole text after append/insert operation |
| 289 | int m_expectedTextLen; |
288 | 290 | }; |
289 | 291 | |
290 | 292 | #endif // _WX_TEXTCTRL_H_ |
diff -uNrb wxWidgets-trunk\src/msw/textctrl.cpp wxWidgets-work\src/msw/textctrl.cpp
old
|
new
|
|
226 | 226 | m_privateContextMenu = NULL; |
227 | 227 | m_updatesCount = -1; |
228 | 228 | m_isNativeCaretShown = true; |
| 229 | m_expectedTextLen = 0; |
229 | 230 | } |
230 | 231 | |
231 | 232 | wxTextCtrl::~wxTextCtrl() |
… |
… |
|
1137 | 1138 | |
1138 | 1139 | UpdatesCountFilter ucf(m_updatesCount); |
1139 | 1140 | |
| 1141 | // Expected text length after the operation. |
| 1142 | m_expectedTextLen = ::GetWindowTextLength(GetHwnd()) + valueDos.length(); |
1140 | 1143 | ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT, |
1141 | 1144 | // EM_REPLACESEL takes 1 to indicate the operation should be redoable |
1142 | 1145 | selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos)); |
| 1146 | if( ::GetWindowTextLength(GetHwnd()) < m_expectedTextLen ) |
| 1147 | { |
| 1148 | // Text size limit has been hit and added text has been truncated. |
| 1149 | // Text buffer has been increased in the background (EN_MAXTEXT message) |
| 1150 | // so we can undo the operation and try to add the text again. |
| 1151 | if( selectionOnly ) |
| 1152 | Undo(); |
| 1153 | ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT, |
| 1154 | // EM_REPLACESEL takes 1 to indicate the operation should be redoable |
| 1155 | selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos)); |
| 1156 | } |
| 1157 | wxASSERT_MSG( ::GetWindowTextLength(GetHwnd()) >= m_expectedTextLen, |
| 1158 | wxT("Insufficient text buffer: appended text has been trucated") ); |
1143 | 1159 | |
1144 | 1160 | if ( !ucf.GotUpdate() && (flags & SetValue_SendEvent) ) |
1145 | 1161 | { |
… |
… |
|
2119 | 2135 | unsigned int len = ::GetWindowTextLength(GetHwnd()); |
2120 | 2136 | if ( len >= limit ) |
2121 | 2137 | { |
2122 | | // increment in 32Kb chunks |
2123 | | SetMaxLength(len + 0x8000); |
| 2138 | unsigned long chunkSize = wxMax(0x8000, m_expectedTextLen - limit); // at least 32KB |
| 2139 | chunkSize = (chunkSize + 0x7FFF) & ~0x7FFF; // round up to the nearest 32KB block |
| 2140 | |
| 2141 | SetMaxLength(len + chunkSize); |
2124 | 2142 | } |
2125 | 2143 | |
2126 | 2144 | // we changed the limit |