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
This commit is contained in:
wp_xxyyzz
2016-06-07 16:42:24 +00:00
parent c4c24a03c9
commit 018aa4e015

View File

@ -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 }