From 0b92a2083d712cb42f80fc9f89f40d058874f0c8 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 26 May 2014 07:30:42 +0000 Subject: [PATCH] Fix setting client data when adding items to a sorted wxListBox, broken in r74317 closes #16290 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/listbox.cpp | 6 +++++- tests/controls/listboxtest.cpp | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 7407fcf5ed..952b509161 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -460,9 +460,13 @@ int wxListBox::DoInsertOneItem(const wxString& item, unsigned int pos) #else int entryCol = 0; #endif - gtk_list_store_insert_with_values(m_liststore, NULL, pos, entryCol, entry, -1); + GtkTreeIter iter; + gtk_list_store_insert_with_values(m_liststore, &iter, pos, entryCol, entry, -1); g_object_unref(entry); + if (HasFlag(wxLB_SORT)) + pos = GTKGetIndexFor(iter); + return pos; } diff --git a/tests/controls/listboxtest.cpp b/tests/controls/listboxtest.cpp index 86659270fb..543b3e1245 100644 --- a/tests/controls/listboxtest.cpp +++ b/tests/controls/listboxtest.cpp @@ -122,9 +122,10 @@ void ListBoxTestCase::Sort() CPPUNIT_ASSERT_EQUAL("aab", m_list->GetString(4)); CPPUNIT_ASSERT_EQUAL("aba", m_list->GetString(5)); - m_list->Append("a"); + m_list->Append("a", wxUIntToPtr(1)); CPPUNIT_ASSERT_EQUAL("a", m_list->GetString(0)); + CPPUNIT_ASSERT_EQUAL(wxUIntToPtr(1), m_list->GetClientData(0)); #endif }