X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a236aa2058ccf3d36e9cafc20fa7375080c4be50..8b375198b712f4f014e7853b7877f3777b31c1b4:/src/msw/choice.cpp diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 4d834267cd..9eec9c2332 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -363,25 +363,22 @@ void wxChoice::SetString(unsigned int n, const wxString& s) // we have to delete and add back the string as there is no way to change a // string in place - // we need to preserve the client data - void *data; - if ( m_clientDataItemsType != wxClientData_None ) - { - data = DoGetItemClientData(n); - } - else // no client data - { - data = NULL; - } + // we need to preserve the client data manually + void *oldData = NULL; + wxClientData *oldObjData = NULL; + if ( HasClientUntypedData() ) + oldData = GetClientData(n); + else if ( HasClientObjectData() ) + oldObjData = GetClientObject(n); ::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0); ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.wx_str() ); - if ( data ) - { - DoSetItemClientData(n, data); - } - //else: it's already NULL by default + // restore the client data + if ( oldData ) + SetClientData(n, oldData); + else if ( oldObjData ) + SetClientObject(n, oldObjData); InvalidateBestSize(); }