Cocoa/ListView: Try to fix the crash caused by Cocoa internal parameter exception during NSTableView initialization on macOS 10.14, #41133

This commit is contained in:
rich2014 2024-09-17 09:34:35 +08:00
parent 43324b497f
commit f27ab84322

View File

@ -70,6 +70,8 @@ type
NSTableViewDelegateProtocol,
NSTableViewDataSourceProtocol,
TCocoaListViewBackendControlProtocol )
private
_coocaInitializing: Boolean;
private
_processor: TCocoaTableViewProcessor;
_checkBoxes: Boolean;
@ -632,6 +634,13 @@ var
begin
inherited;
// NSTableView.initWithFrame() will call setNeedsDisplayInRect()
// at this time, calling rowsInRect() will crash on macOS 10.14.
// it seems that this issue does not exist on other macOS versions.
// FYI: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41133
if _coocaInitializing then
Exit;
rowRange := self.rowsInRect( invalidRect );
if rowRange.length = 0 then
Exit;;
@ -718,7 +727,9 @@ end;
function TCocoaTableListView.initWithFrame(frameRect: NSRect): id;
begin
_coocaInitializing:= True;
Result:=inherited initWithFrame(frameRect);
_coocaInitializing:= False;
if NSAppkitVersionNumber >= NSAppKitVersionNumber11_0 then
setStyle( CocoaConfigListView.vsReport.tableViewStyle );
end;