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;
|
||||
|
||||
TVpResourceCombo = class(TCustomComboBox)
|
||||
protected {private}
|
||||
private
|
||||
FDataStore: TVpCustomDataStore;
|
||||
FPendingDatastore: TVpCustomDatastore;
|
||||
procedure InternalSetDatastore(const Value: TVpCustomDatastore);
|
||||
protected {private}
|
||||
{internal variables}
|
||||
rcLoading: Boolean;
|
||||
OldItemIndex: Integer;
|
||||
FResourceUpdateStyle: TVpResourceUpdate;
|
||||
procedure CreateHandle; override;
|
||||
|
||||
procedure VpDataStoreChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DataStoreChanged;
|
||||
procedure SetDataStore(const Value: TVpCustomDataStore);
|
||||
@ -1256,24 +1260,39 @@ begin
|
||||
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);
|
||||
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
|
||||
if FDataStore <> Value then begin
|
||||
if (Assigned (FDataStore)) and
|
||||
(not (csDesigning in ComponentState)) then
|
||||
FDataStore.DeregisterWatcher (Handle);
|
||||
if Assigned (FDataStore) and not (csDesigning in ComponentState) then
|
||||
FDataStore.DeregisterWatcher(Handle);
|
||||
FDataStore := Value;
|
||||
if (Assigned (FDataStore)) and
|
||||
(not (csDesigning in ComponentState)) then
|
||||
FDataStore.RegisterWatcher (Handle);
|
||||
if Assigned (FDataStore) and not (csDesigning in ComponentState) then
|
||||
FDataStore.RegisterWatcher(Handle);
|
||||
if not (csDesigning in ComponentState) then
|
||||
LoadItems;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user