You've already forked lazarus-ccr
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:
@@ -153,7 +153,7 @@ type
|
||||
property Sender: TObject read FSender write FSender;
|
||||
end;
|
||||
|
||||
TVpResourceCombo = class(TCustomComboBox)
|
||||
TVpResourceCombo = class(TCustomComboBox, IVpWatcher)
|
||||
private
|
||||
FDataStore: TVpCustomDataStore;
|
||||
FPendingDatastore: TVpCustomDatastore;
|
||||
@@ -165,15 +165,19 @@ type
|
||||
FResourceUpdateStyle: TVpResourceUpdate;
|
||||
procedure CreateHandle; override;
|
||||
|
||||
procedure VpDataStoreChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DataStoreChanged;
|
||||
procedure SetDataStore(const Value: TVpCustomDataStore);
|
||||
function GetAbout: string;
|
||||
procedure SetAbout(const Value: string);
|
||||
procedure SetResourceUpdateStyle(const v: TVpResourceUpdate);
|
||||
procedure ResourceChanged(Sender: TObject);
|
||||
procedure LoadItems;
|
||||
{$IFNDEF LCL}
|
||||
|
||||
{$IFDEF LCL}
|
||||
procedure VpDataStoreChanged;
|
||||
procedure VpPrintFormatChanged;
|
||||
{$ELSE}
|
||||
procedure CNCommand (var Msg: TWMCommand); message CN_COMMAND;
|
||||
procedure VpDataStoreChanged(var Msg: TMessage); message Vp_DataStoreChanged;
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
@@ -281,13 +285,13 @@ type
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure DeregisterAllWatchers;
|
||||
procedure DeregisterWatcher(Watcher: THandle);
|
||||
procedure DeregisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
{$IFDEF DEBUG_RESOURCE_GROUPS}
|
||||
procedure DumpResources;
|
||||
{$ENDIF}
|
||||
function GetNextID(TableName: string): Integer; virtual; abstract;
|
||||
procedure NotifyDependents;
|
||||
procedure RegisterWatcher(Watcher: THandle);
|
||||
procedure RegisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
procedure PlaySound(const AWavFile: String; APlaySoundMode: TVpPlaySoundMode);
|
||||
procedure SetResourceByName(Value: string); virtual; abstract;
|
||||
|
||||
@@ -477,7 +481,7 @@ begin
|
||||
inherited;
|
||||
|
||||
FNotifiers := TList.Create;
|
||||
|
||||
|
||||
FAutoCreate := true;
|
||||
FResources := TVpResources.Create(Self);
|
||||
FTimeRange := TVpTimeRange.Create(Self);
|
||||
@@ -602,17 +606,26 @@ var
|
||||
begin
|
||||
if FNotifiers <> nil then
|
||||
for i := FNotifiers.Count - 1 downto 0 do
|
||||
if Assigned(FNotifiers[i]) then begin
|
||||
if Assigned(FNotifiers[i]) then
|
||||
begin
|
||||
{$IFDEF DELPHI}
|
||||
FreeMem(FNotifiers[i]);
|
||||
FNotifiers.Delete (i);
|
||||
{$ENDIF}
|
||||
FNotifiers.Delete(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpCustomDataStore.DeregisterWatcher(Watcher: THandle);
|
||||
procedure TVpCustomDataStore.DeregisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if FNotifiers <> nil then
|
||||
begin
|
||||
{$IFDEF LCL}
|
||||
i := FNotifiers.IndexOf(Watcher);
|
||||
if i <> -1 then
|
||||
FNotifiers.Delete(i);
|
||||
{$ELSE}
|
||||
for i := FNotifiers.Count - 1 downto 0 do
|
||||
if Assigned(FNotifiers[i]) then
|
||||
if PVpWatcher(FNotifiers[i]).Handle = Watcher then begin
|
||||
@@ -620,6 +633,8 @@ begin
|
||||
FNotifiers.Delete(i);
|
||||
Exit;
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpCustomDataStore.dsOnTimer(Sender: TObject);
|
||||
@@ -750,10 +765,22 @@ end;
|
||||
procedure TVpCustomDataStore.NotifyLinked;
|
||||
var
|
||||
i: Integer;
|
||||
{$IFDEF LCL}
|
||||
intf: IVpWatcher;
|
||||
C: TControl;
|
||||
{$ENDIF}
|
||||
begin
|
||||
for i := 0 to FNotifiers.Count - 1 do
|
||||
begin
|
||||
{$IFDEF LCL}
|
||||
C := TControl(FNotifiers[i]);
|
||||
if Assigned(C) and C.GetInterface(GUID_VpWatcher, intf) then
|
||||
intf.VpDatastoreChanged;
|
||||
{$ELSE}
|
||||
if Assigned(FNotifiers[i]) then
|
||||
PostMessage(PVpWatcher(FNotifiers[i]).Handle, Vp_DataStoreChanged, 0, 0);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpCustomDataStore.SetActiveDate(Value: TDateTime);
|
||||
@@ -978,18 +1005,29 @@ begin
|
||||
NotifyDependents;
|
||||
end;
|
||||
|
||||
procedure TVpCustomDataStore.RegisterWatcher(Watcher: THandle);
|
||||
procedure TVpCustomDataStore.RegisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
var
|
||||
i: Integer;
|
||||
{$IFDEF DELPHI}
|
||||
NewHandle: PVpWatcher;
|
||||
{$ENDIF}
|
||||
begin
|
||||
for i := 0 to FNotifiers.Count - 1 do
|
||||
if Assigned (FNotifiers[i]) then
|
||||
if PVpWatcher(FNotifiers[i]).Handle = Watcher then
|
||||
Exit;
|
||||
GetMem(NewHandle, SizeOf(TVpWatcher));
|
||||
NewHandle.Handle := Watcher;
|
||||
FNotifiers.Add(NewHandle);
|
||||
if FNotifiers <> nil then
|
||||
begin
|
||||
{$IFDEF LCl}
|
||||
i := FNotifiers.IndexOf(Watcher);
|
||||
if i = -1 then
|
||||
FNotifiers.Add(Watcher);
|
||||
{$ELSE}
|
||||
for i := 0 to FNotifiers.Count - 1 do
|
||||
if Assigned (FNotifiers[i]) then
|
||||
if PVpWatcher(FNotifiers[i]).Handle = Watcher then
|
||||
Exit;
|
||||
GetMem(NewHandle, SizeOf(TVpWatcher));
|
||||
NewHandle.Handle := Watcher;
|
||||
FNotifiers.Add(NewHandle);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpCustomDataStore.NotifyDependents;
|
||||
@@ -1228,12 +1266,18 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TVpResourceCombo.VpDataStoreChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF});
|
||||
procedure TVpResourceCombo.VpDataStoreChanged({$IFDEF DELPHI}var Msg: TMessage{$ENDIF});
|
||||
begin
|
||||
Unused(Msg);
|
||||
LoadItems;
|
||||
end;
|
||||
|
||||
{$IFDEF LCL}
|
||||
procedure TVpResourceCombo.VpPrintFormatChanged;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function TVpResourceCombo.GetAbout: string;
|
||||
begin
|
||||
Result := VpVersionStr;
|
||||
@@ -1331,10 +1375,10 @@ procedure TVpResourceCombo.InternalSetDatastore(const Value: TVpCustomDatastore)
|
||||
begin
|
||||
if FDataStore <> Value then begin
|
||||
if Assigned (FDataStore) and not (csDesigning in ComponentState) then
|
||||
FDataStore.DeregisterWatcher(Handle);
|
||||
FDataStore.DeregisterWatcher(Self); //Handle);
|
||||
FDataStore := Value;
|
||||
if Assigned (FDataStore) and not (csDesigning in ComponentState) then
|
||||
FDataStore.RegisterWatcher(Handle);
|
||||
FDataStore.RegisterWatcher(Self); //Handle);
|
||||
if not (csDesigning in ComponentState) then
|
||||
LoadItems;
|
||||
Invalidate;
|
||||
|
Reference in New Issue
Block a user