From 912886949a38fe8f00e573337f53d4942bfed14a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 May 2012 14:24:01 +0000 Subject: [PATCH] Check that item ID is initialized when inserting it in wxListCtrl. Using uninitialized ID happened to work by accident with 2.8 but it doesn't work any more, try to detect this as early as possible and give a clear explanation of why it doesn't to help fixing the broken code that used to accidentally work. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71381 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 8d0bead333..3c3e797059 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1656,6 +1656,12 @@ long wxListCtrl::InsertItem(const wxListItem& info) { wxASSERT_MSG( !IsVirtual(), wxT("can't be used with virtual controls") ); + // In 2.8 it was possible to succeed inserting an item without initializing + // its ID as it defaulted to 0. This was however never supported and in 2.9 + // the ID is -1 by default and inserting it simply fails, but it might be + // not obvious why does it happen, so check it proactively. + wxASSERT_MSG( info.m_itemId != -1, wxS("Item ID must be set.") ); + LV_ITEM item; wxConvertToMSWListItem(this, info, item); item.mask &= ~LVIF_PARAM; -- 2.45.2