From 018aa4e015e7d2da3d88de886bca18082028a428 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 7 Jun 2016 16:42:24 +0000 Subject: [PATCH] tvplanit: modified flexdatastore so that it should correctly check if any dataset is linked. (patch from forum user "magu", http://forum.lazarus.freepascal.org/index.php/topic,32871.msg212397.html#msg212397, most of the other commits of today are based on magu's work). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4685 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpflxds.pas | 39 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/components/tvplanit/source/vpflxds.pas b/components/tvplanit/source/vpflxds.pas index 841ac14de..97aa8029f 100644 --- a/components/tvplanit/source/vpflxds.pas +++ b/components/tvplanit/source/vpflxds.pas @@ -287,6 +287,8 @@ end; {=====} procedure TVpFlexDataStore.SetConnected(const Value: boolean); +var + rststrikes: Integer; begin { disconnect if destroying } if csDestroying in ComponentState then Exit; @@ -302,11 +304,44 @@ begin and (FTasksDataSrc = nil) then Exit; - if (FResourceDataSrc.Dataset = nil) + rststrikes := 0; + // basically a Src can fail either if (a) it is completely nil, or (b) only the dataset is nil + if (FResourceDataSrc <> nil) then begin + if (FResourceDataSrc.Dataset = nil) then begin + inc(rststrikes) + end; + end else + inc(rststrikes); + + if (FEventsDataSrc <> nil) then begin + if (FEventsDataSrc.Dataset = nil) then begin + inc(rststrikes) + end; + end else + inc(rststrikes); + + if (FContactsDataSrc <> nil) then begin + if (FContactsDataSrc.Dataset = nil) then begin + inc(rststrikes) + end; + end else + inc(rststrikes); + + if (FTasksDataSrc <> nil) then begin + if (FTasksDataSrc.Dataset = nil) then begin + inc(rststrikes) + end; + end else + inc(rststrikes); + + //if no datasrc is set then exit + if rststrikes >= 4 then Exit; + + {if (FResourceDataSrc.Dataset = nil) and (FEventsDataSrc.Dataset = nil) and (FContactsDataSrc.Dataset = nil) and (FTasksDataSrc.Dataset = nil) - then Exit; + then Exit; } if Value then begin { try to open the tables one at a time. If they fail, and AutoCreate is }