From f81256b3512794cbe85a02c79bfc6e0ecb96fafc Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 29 Sep 2018 23:00:35 +0000 Subject: [PATCH] tvplanit: Fix JSONDatastore deleting data file when started next time. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6669 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/examples/datastores/json/unit1.pas | 2 +- components/tvplanit/source/vpjsonds.pas | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/tvplanit/examples/datastores/json/unit1.pas b/components/tvplanit/examples/datastores/json/unit1.pas index fd3fbd2bc..4c64d8746 100644 --- a/components/tvplanit/examples/datastores/json/unit1.pas +++ b/components/tvplanit/examples/datastores/json/unit1.pas @@ -4,7 +4,7 @@ unit Unit1; { Activate this define to use a JSON string instead of a file } -{$DEFINE USE_JSON_STRING} +{.$DEFINE USE_JSON_STRING} interface diff --git a/components/tvplanit/source/vpjsonds.pas b/components/tvplanit/source/vpjsonds.pas index ceab4c81b..9f8301a3f 100644 --- a/components/tvplanit/source/vpjsonds.pas +++ b/components/tvplanit/source/vpjsonds.pas @@ -431,8 +431,8 @@ end; procedure TVpJSONDatastore.Loaded; begin inherited; - if not (csDesigning in ComponentState) then - Connected := AutoConnect; + if not (csDesigning in ComponentState) and AutoConnect then + Connected := true; end; procedure TVpJSONDatastore.LoadEvents; @@ -615,6 +615,9 @@ begin if (csDesigning in ComponentState) or (csLoading in ComponentState) then Exit; + if Value = Connected then + exit; + { Connecting or disconnecting? } if Value then ReadJSON