mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 05:25:58 +02:00
* Fix memleaks (bug ID 36408)
git-svn-id: trunk@43662 -
This commit is contained in:
parent
147a766890
commit
04a51a622d
@ -1,15 +1,15 @@
|
|||||||
program devds;
|
program testjsondataset;
|
||||||
|
|
||||||
{$DEFINE TESTCALCFIELDS}
|
{$DEFINE TESTCALCFIELDS}
|
||||||
{$DEFINE TESTLOOKUPFIELDS}
|
{$DEFINE TESTLOOKUPFIELDS}
|
||||||
|
|
||||||
uses variants, varutils, sysutils, db, fpjson , fpjsondataset, ExtJSDataset, types;
|
uses classes, variants, varutils, sysutils, db, fpjson , fpjsondataset, ExtJSDataset, types;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
|
|
||||||
{ TApp }
|
{ TApp }
|
||||||
|
|
||||||
TApp = Class(TObject)
|
TApp = Class(TComponent)
|
||||||
private
|
private
|
||||||
DS : TExtJSJSONObjectDataSet;
|
DS : TExtJSJSONObjectDataSet;
|
||||||
DC : TExtJSJSONObjectDataSet;
|
DC : TExtJSJSONObjectDataSet;
|
||||||
@ -70,7 +70,7 @@ Var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Writeln('Creating dataset');
|
Writeln('Creating dataset');
|
||||||
DS:=TExtJSJSONObjectDataSet.Create(Nil);
|
DS:=TExtJSJSONObjectDataSet.Create(Self);
|
||||||
DS.MetaData:=GetJSON('{ "fields" : [ '+
|
DS.MetaData:=GetJSON('{ "fields" : [ '+
|
||||||
' { "name": "firstname"}, '+
|
' { "name": "firstname"}, '+
|
||||||
' { "name": "lastname"}, '+
|
' { "name": "lastname"}, '+
|
||||||
@ -85,7 +85,7 @@ begin
|
|||||||
' {"firstname" : "Bruno", "lastname" : "Fierens", "children" : 3, "birthday" : "1970-07-09", "business" : true, "weight": 77.3, "country": "BE" },'+
|
' {"firstname" : "Bruno", "lastname" : "Fierens", "children" : 3, "birthday" : "1970-07-09", "business" : true, "weight": 77.3, "country": "BE" },'+
|
||||||
' {"firstname" : "Detlef", "lastname" : "Overbeek", "children" : 2, "birthday" : "1950-07-08", "business" : true, "weight": 78.8, "country": "NL" }'+
|
' {"firstname" : "Detlef", "lastname" : "Overbeek", "children" : 2, "birthday" : "1950-07-08", "business" : true, "weight": 78.8, "country": "NL" }'+
|
||||||
' ]') as TJSONArray;
|
' ]') as TJSONArray;
|
||||||
DC:=TExtJSJSONObjectDataSet.Create(Nil);
|
DC:=TExtJSJSONObjectDataSet.Create(Self);
|
||||||
DC.MetaData:=GetJSON('{ "fields" : [ '+
|
DC.MetaData:=GetJSON('{ "fields" : [ '+
|
||||||
' { "name": "code"}, '+
|
' { "name": "code"}, '+
|
||||||
' { "name": "name"} '+
|
' { "name": "name"} '+
|
||||||
@ -174,7 +174,7 @@ begin
|
|||||||
Writeln('Modified before (expect False): ',DS.Modified);
|
Writeln('Modified before (expect False): ',DS.Modified);
|
||||||
DumpRecord(DS);
|
DumpRecord(DS);
|
||||||
DS.FieldByName('firstname').AsString:='Florian';
|
DS.FieldByName('firstname').AsString:='Florian';
|
||||||
Writeln('Old value of field first name (expect null): ', DS.FieldByName('firstname').OldValue);
|
Writeln('Old value of field first name (expect null): ', varisNull(DS.FieldByName('firstname').OldValue) );
|
||||||
DS.FieldByName('lastname').AsString:='Klaempfl';
|
DS.FieldByName('lastname').AsString:='Klaempfl';
|
||||||
DS.FieldByName('children').AsInteger:=1;
|
DS.FieldByName('children').AsInteger:=1;
|
||||||
DS.FieldByName('birthday').AsDateTime:=EncodeDate(1980,5,4);
|
DS.FieldByName('birthday').AsDateTime:=EncodeDate(1980,5,4);
|
||||||
@ -288,7 +288,7 @@ begin
|
|||||||
DSS:=Nil;
|
DSS:=Nil;
|
||||||
t:=TDataLink.Create;
|
t:=TDataLink.Create;
|
||||||
try
|
try
|
||||||
DSS:=TDatasource.Create(Nil);
|
DSS:=TDatasource.Create(self);
|
||||||
DSS.DataSet:=DS;
|
DSS.DataSet:=DS;
|
||||||
Writeln('Buffercount');
|
Writeln('Buffercount');
|
||||||
t.BufferCount := 10;
|
t.BufferCount := 10;
|
||||||
@ -323,6 +323,7 @@ begin
|
|||||||
DSS:=Nil;
|
DSS:=Nil;
|
||||||
t:=TDataLink.Create;
|
t:=TDataLink.Create;
|
||||||
try
|
try
|
||||||
|
DSS:=TDatasource.Create(Self);
|
||||||
DSS.DataSet:=DS;
|
DSS.DataSet:=DS;
|
||||||
DSS.DataSet:=DS;
|
DSS.DataSet:=DS;
|
||||||
t.DataSource := DSS;
|
t.DataSource := DSS;
|
||||||
@ -421,9 +422,9 @@ begin
|
|||||||
|
|
||||||
DC.Open;
|
DC.Open;
|
||||||
DS.Open;
|
DS.Open;
|
||||||
// TestLocate;
|
TestLocate;
|
||||||
TestLookup;
|
TestLookup;
|
||||||
exit;
|
// exit;
|
||||||
TestNavigation;
|
TestNavigation;
|
||||||
TestAppend;
|
TestAppend;
|
||||||
TestEdit;
|
TestEdit;
|
||||||
@ -444,7 +445,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
With Tapp.Create do
|
With Tapp.Create(nil) do
|
||||||
Run;
|
try
|
||||||
|
Run;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user