Mercurial > p > dcplusplus > code
changeset 3994:8f6406972c64
Fix TypedTable / ListView item text truncation that's done when text length is longer than maximum allowed - prevents a display issue of garbage being padded to the end of these items in the lists
author | eMTee <emtee11@gmail.com> |
---|---|
date | Mon, 15 Apr 2024 17:31:07 +0200 |
parents | 1a59791ebf13 |
children | e72b0c30a895 |
files | win32/TypedTable.h |
diffstat | 1 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/win32/TypedTable.h Sat Apr 13 11:22:09 2024 +0200 +++ b/win32/TypedTable.h Mon Apr 15 17:31:07 2024 +0200 @@ -268,10 +268,9 @@ define_if(HasText, void) handleText(NMLVDISPINFO& data) { ContentType* content = reinterpret_cast<ContentType*>(data.item.lParam); const tstring& text = content->getText(data.item.iSubItem); - _tcsncpy(data.item.pszText, text.data(), std::min(text.size(), static_cast<size_t>(data.item.cchTextMax))); - if(text.size() < static_cast<size_t>(data.item.cchTextMax)) { - data.item.pszText[text.size()] = 0; - } + const size_t length = std::min(text.size(), static_cast<size_t>(data.item.cchTextMax) - 1); + _tcsncpy(data.item.pszText, text.data(), length); + data.item.pszText[length] = 0; } define_if(HasImage, void) handleImage(NMLVDISPINFO& data) {