Opened 7 months ago

Closed 7 months ago

#16290 closed defect (fixed)

Storing client data in sorted wxListBox on GTK is broken

Reported by: HighCommander4 Owned by: PC
Priority: normal Milestone:
Component: wxGTK Version: 3.0.0
Keywords: regression Cc:
Blocked By: Blocking:
Patch: no

Description

Steps to reproduce:

Build and run the following code on Linux.
I used Ubuntu 10.04.

    #include <wx/wx.h>
    #include <iostream>
    
    class MyFrame : public wxFrame
    {
    public:
        MyFrame() : wxFrame(nullptr, wxID_ANY, "")
        {
            wxListBox* listbox = new wxListBox(this,
                                               wxID_ANY,
                                               wxDefaultPosition,
                                               wxDefaultSize,
                                               0,
                                               nullptr,
                                               wxLB_SORT);
            listbox->Append("B", (void*)2);
            listbox->Append("A", (void*)1);
    
            std::cout << "client data at index 0: " << listbox->GetClientData(0) << "\n";
            std::cout << "client data at index 1: " << listbox->GetClientData(1) << "\n";
        }
    private:
    };
    
    class MyApp : public wxApp
    {
    public:
        virtual bool OnInit()
        {
            MyFrame *frame = new MyFrame;
            frame->Show(true);
            return true;
        }
    };
    
    wxIMPLEMENT_APP(MyApp);

Expected output:

client data at index 0: 0x1
client data at index 1: 0x2

Actual output:

client data at index 0: 0
client data at index 1: 0x1

Notes:

  • This was tested with wxWidgets 3.0.0. It used to work with wxWidgets 2.9.5. Therefore, this is a regression.
  • This example works fine on Windows. Therefore, the regression is GTK-specific.
  • The problem only occurs when the items are added to the list box in an order different from the sorted order. That is, if I add "A" before "B", it works fine.

Change History (1)

comment:1 Changed 7 months ago by PC

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

In 76605:

Fix setting client data when adding items to a sorted wxListBox, broken in r74317
closes #16290

Note: See TracTickets for help on using tickets.