From f436b26383526f6005fbe239056ab2a34215ae07 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 14 Sep 2016 22:39:33 +0000 Subject: [PATCH] tvplanit: Fix fulldemo with resource groups crashing due to nil resources. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5161 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpbaseds.pas | 15 +++++++++++---- components/tvplanit/source/vpdata.pas | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/tvplanit/source/vpbaseds.pas b/components/tvplanit/source/vpbaseds.pas index 2defa0d61..b4ee59604 100644 --- a/components/tvplanit/source/vpbaseds.pas +++ b/components/tvplanit/source/vpbaseds.pas @@ -819,6 +819,7 @@ var i: Integer; event: TVpEvent; id: Integer; + res: TVpResource; begin Resource.Schedule.ClearGroupEvents; @@ -828,10 +829,16 @@ begin end; for i:=0 to Resource.Group.Count-1 do begin - id := Resource.Group[i].ResourceID; - if id = ResourceID then - exit; - LoadEventsOfResource(id); + // current resource of group + res := Resource.Group[i]; + if res <> nil then begin + id := res.ResourceID; + // Ignore active resource in group + if id = ResourceID then + Continue; + // Load events of the current resource of the group + LoadEventsOfResource(id); + end; end; NotifyDependents; diff --git a/components/tvplanit/source/vpdata.pas b/components/tvplanit/source/vpdata.pas index 9ae1bf995..8d477050c 100644 --- a/components/tvplanit/source/vpdata.pas +++ b/components/tvplanit/source/vpdata.pas @@ -752,7 +752,8 @@ begin if ACaption = '' then begin for i:=Low(AResIDs) + 1 to High(AResIDs) do begin res := GetResource(AResIDs[i]); - ACaption := ACaption + ', ' + res.Description; + if res <> nil then + ACaption := ACaption + ', ' + res.Description; end; if ACaption <> '' then Delete(ACaption, 1, 2); end;