Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14892 closed defect (fixed)

wxBitmapComboBox::SetItemBitmap clear client object pointer.

Reported by: Feneck91 Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 2.9.4
Keywords: wxBitmapComboBox SetItemBitmap GetClientObject regression Cc:
Blocked By: Blocking:
Patch: yes


When creating a wxBitmapComboBox control under Windows, calling SetItemBitmap clear the client object on item.

To make it, create a wxBitmapComboBox, add a new item without bitmap that contains a client object. Then set the bitmap : the client object is now set to null.

It's works well on wxWidgets 2.8.12, fails on wxWidgets 2.9.4

wxBitmapComboBox *pCombo = new wxBitmapComboBox(this, idChoiceCtrlListTeam1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY, wxDefaultValidator, _T("idChoiceCtrlListTeam1"));

pCombo->Insert(wxT("my text"),wxNullBitmap,0,new wxClientData());

wxBitmap myImage(wxImage(_T("myImage.png"));


wxASSERT_MSG(pCombo->GetClientObject(0) != NULL,wxT("Client data is NULL !"));


To set the item text and bitmap, I must use the code: 

void SetItem(wxString strText,int iIndex,wxBitmap bitmap)


#if wxCHECK_VERSION(2,9,0)

Calling SetItemBitmap remove wxClientData item, change way of how the item is inserted

bool bSelected = this->IsSelected(iIndex);

wxClientData *pClient = m_pCombo->DetachClientObject (iIndex);



if (bSelected)




wxASSERT_MSG(pCombo->GetClientObject(_iIndex) != NULL,wxT("Client data is NULL !"));






Attachments (2)

14892test.diff download (1.5 KB) - added by catalin 5 years ago.
14892fix.diff download (886 bytes) - added by catalin 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by vadz

  • Keywords regression added
  • Priority changed from high to normal

It would be great if you could please make a patch to the combo sample allowing to reproduce the problem with the minimal amount of code to allow me to debug this easily.

Of course, if you could debug it yourself and make a patch fixing the problem, it would be even greater, please consider doing it, it shouldn't be very difficult to see what is going on wrong here but I just don't have enough time for it.

Changed 5 years ago by catalin

Changed 5 years ago by catalin

comment:2 Changed 5 years ago by catalin

  • Patch set

Saving the pointers to old client data (it is not deleted) and using them when the control is recreated fixes this problem. Patches attached.

comment:3 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73567]) Preserve client data pointers when setting bitmaps in wxBitmapComboBox.

Changing the bitmap could recreate the control if the height of the bitmap
changed but recreating wxBitmapComboBox lost all the client data pointers.

Do preserve them now when recreating.

Closes #14892.

comment:4 Changed 5 years ago by VZ

(In [73880]) Fix assert when adding items with bitmaps wxBitmapComboBox.

The change of r73567 resulted in an assert when adding items with bitmaps to
wxBitmapComboBox without object client data. Fix the code added by this commit
to work for all kinds of client data, including wxClientData_None.

See #14892.

Note: See TracTickets for help on using tickets.