wxString::Truncates() now doesn't change the sharied copies of the string

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1226 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-12-17 20:23:13 +00:00
parent a43a4f9d4d
commit 79a773ba60

View File

@@ -899,8 +899,13 @@ wxString& wxString::Pad(size_t nCount, char chPad, bool bFromRight)
// truncate the string
wxString& wxString::Truncate(size_t uiLen)
{
*(m_pchData + uiLen) = '\0';
GetStringData()->nDataLength = uiLen;
if ( uiLen < Len() ) {
CopyBeforeWrite();
*(m_pchData + uiLen) = '\0';
GetStringData()->nDataLength = uiLen;
}
//else: nothing to do, string is already short enough
return *this;
}