Skip to content

Tolerate AValue = nil in TCocoaWSCustomListView.SetImageList

Michalis Kamburelis requested to merge michaliskambi/lazarus:main into main

Before applying this PR, loading the attached project in latest Lazarus fails with "Access Violation" at design-time. Just opening the project in Lazarus IDE should trigger the error (or one can explicitly open unit1 and view form by Alt + Command + F).


It seems the problem was introduced in 221b2cef , that added access to AValue.Height inside TCocoaWSCustomListView.SetImageList, but without checking if AValue <> nil first. Debugging the attached test project shows that the AValue in this case indeed is nil, thus explaining the crash at accessing AValue.Height.

Note: The earlier code in TCocoaWSCustomListView.SetImageList does lTableLV.lclSetImagesInCell(Assigned(AValue)); so it seems that older code was prepared for AValue = nil case.

Tested and problem reproduced with

  • Lazarus 3.2,
  • and latest Lazarus "main" revision from GitLab ( 346b890f ).

Note: This particular testcase doesn't crash at run-time. For unknown reason, "just running it" goes OK. But it is cut-down version of a similar form in Castle Game Engine editor -- and in CGE case, we have the crash also at run-time. See thread . The submitter (Sophia) there confirmed it is also reproducible with Lazarus 3.4.

This trivial PR fixes it. When "AValue = nil", we just exit early, as if "AValue.Height < lTableLV.rowHeight-2" was true.

Merge request reports