From da6069e29c0dd892eb2e55e4314499f68fb4c02b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 26 Nov 2001 11:24:14 +0000 Subject: [PATCH] fix for incorrect assert in SetClientObject git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/ctrlsub.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/common/ctrlsub.cpp b/src/common/ctrlsub.cpp index abbaabb4ff..1d8421d728 100644 --- a/src/common/ctrlsub.cpp +++ b/src/common/ctrlsub.cpp @@ -61,12 +61,22 @@ void wxItemContainer::SetClientObject(int n, wxClientData *data) wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void, wxT("can't have both object and void client data") ); - wxClientData *clientDataOld = DoGetItemClientObject(n); - if ( clientDataOld ) - delete clientDataOld; + // when we call SetClientObject() for the first time, m_clientDataItemsType + // is still wxClientData_None and so calling DoGetItemClientObject() would + // fail (in addition to being useless) - don't do it + if ( m_clientDataItemsType == wxClientData_Object ) + { + wxClientData *clientDataOld = DoGetItemClientObject(n); + if ( clientDataOld ) + delete clientDataOld; + } + else // m_clientDataItemsType == wxClientData_None + { + // now we have object client data + m_clientDataItemsType = wxClientData_Object; + } DoSetItemClientObject(n, data); - m_clientDataItemsType = wxClientData_Object; } wxClientData *wxItemContainer::GetClientObject(int n) const