TvPlanIt: Fix cocoa crashing due to windows-like message VP_DatastoreChanged.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8887 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-07-20 22:43:28 +00:00
parent 319c3452e0
commit d5965cb872
4 changed files with 118 additions and 38 deletions

View File

@ -111,7 +111,7 @@ type
end;
{ Contact Grid }
TVpContactGrid = class(TVpLinkableControl)
TVpContactGrid = class(TVpLinkableControl, IVpWatcher)
private
FCol1RecCount: Integer;
FComponentHint: TTranslateString;
@ -211,6 +211,13 @@ type
procedure EditContact;
procedure EndEdit(Sender: TObject);
{$IFDEF LCL}
procedure VpDataStoreChanged;
procedure VpPrintFormatChanged;
{$ELSE}
procedure VpDataStoreChanged(var Msg: TMessage); message VP_DatastoreChanged;
{$ENDIF}
{ popup menu }
function GetPopupMenu: TPopupMenu; override;
procedure InitializeDefaultPopup;
@ -228,7 +235,6 @@ type
procedure WMSetCursor(var Msg: TWMSetCursor);
procedure WMLButtonDblClk(var Msg : TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
procedure WMKillFocus(var Msg : TWMKillFocus); message WM_KILLFOCUS;
procedure VpDataStoreChanged (var Msg : TMessage); message Vp_DataStoreChanged;
{$ELSE}
procedure WMSize(var Msg: TLMSize); message LM_SIZE;
procedure WMHScroll(var Msg: TLMHScroll); message LM_HSCROLL;
@ -556,7 +562,7 @@ end;
destructor TVpContactGrid.Destroy;
begin
if HandleAllocated and Assigned(DataStore) and (not (csDesigning in ComponentState)) then
DataStore.DeregisterWatcher(Handle);
DataStore.DeregisterWatcher(Self); //Handle);
cgClickTimer.Free;
FContactHeadAttr.Free;
@ -1945,15 +1951,19 @@ begin
Invalidate;
end;
{$IFNDEF LCL}
procedure TVpContactGrid.VpDataStoreChanged (var Msg : TMessage);
{ The DataStore's Resource may not have been properly set (that is:
the DataStore existed, but there was no resource. Force the sortby
on the contacts here }
procedure TVpContactGrid.VpDataStoreChanged({$IFDEF DELPHI}var Msg: TMessage{$ENDIF});
begin
{ The DataStore's Resource may not have been property set (that is
the DataStore existed, but there was no resource. Force the sortby
on the contacts here }
if Assigned (DataStore) then
if Assigned (DataStore.Resource) then
DataStore.Resource.Contacts.ContactSort := SortBy;
if Assigned(DataStore) and Assigned(DataStore.Resource) then
DataStore.Resource.Contacts.ContactSort := SortBy;
end;
{$IFDEF LCL}
procedure TVpContactGrid.VpPrintFormatChanged;
begin
//
end;
{$ENDIF}
@ -2017,12 +2027,12 @@ end;
procedure TVpContactGrid.InternalSetDatastore(const Value: TVpCustomDatastore);
begin
if Assigned (DataStore) and not (csDesigning in ComponentState) then
DataStore.DeregisterWatcher(Handle);
DataStore.DeregisterWatcher(Self); //Handle);
inherited SetDataStore(Value);
if Assigned (DataStore) and not (csDesigning in ComponentState) then
DataStore.RegisterWatcher(Handle);
DataStore.RegisterWatcher(Self); //Handle);
if not Assigned(DataStore) then
Exit;