You've already forked lazarus-ccr
TvPlanIt: Fix TVpResourceCombo crashing when used in a frame ("... has no parent")
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8353 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -150,12 +150,16 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
TVpResourceCombo = class(TCustomComboBox)
|
TVpResourceCombo = class(TCustomComboBox)
|
||||||
protected {private}
|
private
|
||||||
FDataStore: TVpCustomDataStore;
|
FDataStore: TVpCustomDataStore;
|
||||||
|
FPendingDatastore: TVpCustomDatastore;
|
||||||
|
procedure InternalSetDatastore(const Value: TVpCustomDatastore);
|
||||||
|
protected {private}
|
||||||
{internal variables}
|
{internal variables}
|
||||||
rcLoading: Boolean;
|
rcLoading: Boolean;
|
||||||
OldItemIndex: Integer;
|
OldItemIndex: Integer;
|
||||||
FResourceUpdateStyle: TVpResourceUpdate;
|
FResourceUpdateStyle: TVpResourceUpdate;
|
||||||
|
procedure CreateHandle; override;
|
||||||
|
|
||||||
procedure VpDataStoreChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DataStoreChanged;
|
procedure VpDataStoreChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DataStoreChanged;
|
||||||
procedure SetDataStore(const Value: TVpCustomDataStore);
|
procedure SetDataStore(const Value: TVpCustomDataStore);
|
||||||
@ -1256,24 +1260,39 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
procedure TVpResourceCombo.CreateHandle;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if FPendingDatastore <> nil then
|
||||||
|
begin
|
||||||
|
InternalSetDatastore(FPendingDatastore);
|
||||||
|
FPendingDatastore := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpResourceCombo.SetDataStore(const Value: TVpCustomDataStore);
|
procedure TVpResourceCombo.SetDataStore(const Value: TVpCustomDataStore);
|
||||||
|
begin
|
||||||
|
if HandleAllocated then
|
||||||
|
InternalSetDatastore(Value)
|
||||||
|
else
|
||||||
|
// Delay linking of the datastore until the Handle has been created.
|
||||||
|
FPendingDatastore := Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpResourceCombo.InternalSetDatastore(const Value: TVpCustomDatastore);
|
||||||
begin
|
begin
|
||||||
if FDataStore <> Value then begin
|
if FDataStore <> Value then begin
|
||||||
if (Assigned (FDataStore)) and
|
if Assigned (FDataStore) and not (csDesigning in ComponentState) then
|
||||||
(not (csDesigning in ComponentState)) then
|
FDataStore.DeregisterWatcher(Handle);
|
||||||
FDataStore.DeregisterWatcher (Handle);
|
|
||||||
FDataStore := Value;
|
FDataStore := Value;
|
||||||
if (Assigned (FDataStore)) and
|
if Assigned (FDataStore) and not (csDesigning in ComponentState) then
|
||||||
(not (csDesigning in ComponentState)) then
|
FDataStore.RegisterWatcher(Handle);
|
||||||
FDataStore.RegisterWatcher (Handle);
|
|
||||||
if not (csDesigning in ComponentState) then
|
if not (csDesigning in ComponentState) then
|
||||||
LoadItems;
|
LoadItems;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user