Interesting discovery with TListView with OwnerData checked and Adding items. lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2024-03-17 21:56 If you have OwnerData checked and then use the IDE to add items, upon completion of the editor, you get a nice Index of bounds with the trunk.   Older IDE's, it puts the IDE into a loop and you need to hard exit. ---------------------------------------------------------------------- dsiders · 2024-03-17 22:46 Quote from: jamie on March 17, 2024, 10:56:36 pm If you have OwnerData checked and then use the IDE to add items, upon completion of the editor, you get a nice Index of bounds with the trunk.   Older IDE's, it puts the IDE into a loop and you need to hard exit. Interesting. So, in essence, the property editor should not be displayed at all when OwnerData is enabled? ---------------------------------------------------------------------- jamie · 2024-03-17 22:51 I would say so. Not just that, the items should be deleted if one checks the ownerdata too. ---------------------------------------------------------------------- dsiders · 2024-03-18 01:17 Quote from: jamie on March 17, 2024, 11:51:58 pmI would say so. Not just that, the items should be deleted if one checks the ownerdata too. SetOwnerData already does that. It frees the Items list are creates the TOwnerDataListItems container used instead. I made a patch (for 3.99) to catch the circumstance you described, if you'd like to try it out... Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/components/ideintf/listviewpropedit.pp b/components/ideintf/listviewpropedit.ppindex 0fc4ca719d..73ba02c024 100644--- a/components/ideintf/listviewpropedit.pp+++ b/components/ideintf/listviewpropedit.pp@@ -92,6 +92,13 @@ function EditListView(AListView: TListView): Boolean; var   ListViewEditorDlg: TListViewItemsEditorForm; begin+  if AListView.OwnerData then+  begin+    Beep;+    Application.MessageBox(PChar(sccsLvEdtMsgOwnerData), PChar(sccsLvEdt));+    Result := False;+    Exit;+  end;   ListViewEditorDlg := TListViewItemsEditorForm.Create(Application);   try     ListViewEditorDlg.LoadFromList(AListView);diff --git a/components/ideintf/objinspstrconsts.pas b/components/ideintf/objinspstrconsts.pasindex 27366703fb..17099884ca 100644--- a/components/ideintf/objinspstrconsts.pas+++ b/components/ideintf/objinspstrconsts.pas@@ -134,6 +134,7 @@ resourcestring   sccsLvEdtLabelImageIndex = 'Image Index:';   sccsLvEdtLabelStateIndex = 'State Index:';   sccsLvEdtItem            = 'Item';+  sccsLvEdtMsgOwnerData    = 'Cannot edit list items at design-time when OwnerData is enabled. Use Items.Count and OnData at run-time instead.';    // Image editor strings   oisImageListComponentEditor = 'I&mageList Editor ...';   The Beep and Application.MessageBox calls are debatable, but they did not introduce any new dependencies in the unit. ---------------------------------------------------------------------- wp · 2024-03-18 10:09 I don't like the Beep. Is a Beep used within the IDE anywhere else? And I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something? ---------------------------------------------------------------------- jamie · 2024-03-18 12:23 I am not sure if the ondata event is even working? ---------------------------------------------------------------------- dsiders · 2024-03-18 15:47 Quote from: wp on March 18, 2024, 11:09:16 amI don't like the Beep. Is a Beep used within the IDE anywhere else? Not in the IDE specifically, but in LCL bring-to-front flash-and-beep behavior. Quote from: wp on March 18, 2024, 11:09:16 amAnd I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something? No, you're not missing anything. I just took the path of least resistance. ---------------------------------------------------------------------- dsiders · 2024-03-18 15:48 Quote from: jamie on March 18, 2024, 01:23:35 pmI am not sure if the ondata event is even working? If it's not, then how are you getting values for from the virtual data container? ---------------------------------------------------------------------- wp · 2024-03-18 16:17 Quote from: jamie on March 18, 2024, 01:23:35 pmI am not sure if the ondata event is even working? Here's a demo with 1,000,000 items in a virtual listview. ---------------------------------------------------------------------- wp · 2024-03-18 16:18 Quote from: dsiders on March 18, 2024, 04:47:01 pmQuote from: wp on March 18, 2024, 11:09:16 amI don't like the Beep. Is a Beep used within the IDE anywhere else? Not in the IDE specifically, but in LCL bring-to-front flash-and-beep behavior. Quote from: wp on March 18, 2024, 11:09:16 amAnd I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something? No, you're not missing anything. I just took the path of least resistance. OK when I commit it? ---------------------------------------------------------------------- dsiders · 2024-03-18 16:29 Quote from: wp on March 18, 2024, 05:18:55 pmQuote from: dsiders on March 18, 2024, 04:47:01 pmQuote from: wp on March 18, 2024, 11:09:16 amI don't like the Beep. Is a Beep used within the IDE anywhere else? Not in the IDE specifically, but in LCL bring-to-front flash-and-beep behavior. Quote from: wp on March 18, 2024, 11:09:16 amAnd I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something? No, you're not missing anything. I just took the path of least resistance. OK when I commit it? Here's the modified version. ---------------------------------------------------------------------- wp · 2024-03-18 20:11 Committed (https://gitlab.com/freepascal.org/lazarus/lazarus/- /commit/5621ec7af3f8d08bf514edb72defc0045ab3ee26), will be backported to Laz/Fixes and the next bug-fix release v3.4 ---------------------------------------------------------------------- n7800 · 2024-06-06 05:51 I would like to propose another solution to this problem. I suggest printing a message when trying to set OwnerData if the items are not empty. The user should be warned about the loss of items and delete them themselves. This is a more correct way. Maybe I'll make a patch myself, but I don't have time yet. Feel free to do it yourself.