Hi,
I am getting a floating point error on a TROComplexType.Destroy. In the forum there are links to a wiki do on serialization but the link is no longer valid, like here:
Can you help?
Hi,
I am getting a floating point error on a TROComplexType.Destroy. In the forum there are links to a wiki do on serialization but the link is no longer valid, like here:
Can you help?
Hi,
I’ve uploaded that article to Remote Object Allocation and Serialization (Delphi).
note: Link will be available in ~30 min.
Hi,
Ok that helps but my schenario is a bit different.
My function has a result that is an array type. Below is a simplified sample.
Always free the memory on the client and never free it on the server .
So what am I doing wrong here?
function TMyService.GetData: MyArrayofMyOIbject;
var
MyObject: TMyObject;
MyArray: MyArrayofMyOIbject;
begin
MyObject := TMyObject.Create;
MyObject.SomeData = 123;
MyArray.Add(MyObject);
MyObject := TMyObject.Create;
MyObject.SomeData = 456;
MyArray.Add(MyObject);
Result := MyArray;
end;
Hi,
you have to create MyArray
like
function TMyService.GetData: MyArrayofMyOIbject;
var
MyObject: TMyObject;
MyArray: MyArrayofMyOIbject;
begin
MyArray:= MyArrayofMyOIbject.Create; ///<<<<<<<<<<
Sorry I left that out in the example but have it in my implementation.
When I call the Service with my GetData call I get the Invalid Pointer Error.
Thanks,
can you privide callstack for that error, pls?
Hi,
can you create a simple testcase that reproduce this error, pls?
this code shouldn’t raise any issues:
function TMyService.GetData: MyArrayofMyOIbject;
var
MyObject: TMyObject;
MyArray: MyArrayofMyOIbject;
begin
MyArray:= MyArrayofMyOIbject.Create;
MyObject := TMyObject.Create;
MyObject.SomeData = 123;
MyArray.Add(MyObject);
MyObject := TMyObject.Create;
MyObject.SomeData = 456;
MyArray.Add(MyObject);
Result := MyArray;
end;
except you freed MyObject
manually after adding it to array
I’ve created a sample project by copying the RODL into a blank project and creating some of the objects in the same way they are create in my app.
However in my test app the function returns nil but also does not show the error. Can you take a look?
ROTest.zip (129.4 KB)
hi,
as expected:
server-side:
function TTrafficLog.GetLog(const StationID: ROAnsiString; const Date: DateTime): Breaks;
begin
{$Message Hint 'GetLog is not implemented yet!'}
result := nil;
exit;
end;
client-side:
ABreaks := (RORemoteService as ITrafficLog).GetLog(StationID,Date);
Hello,
Ok that makes sense.
If you add this to Get Log that should help.
function TTrafficLog.GetLog(const StationID: ROAnsiString; const Date: DateTime): Breaks;
begin
LoadData(0,EncodeDate(2020,1,1),ENcodeTime(1,1,1,1),ENcodeTime(1,1,1,1));
end;
Hi,
it works as expected:
Note:I’ve used
function TTrafficLog.GetLog(const StationID: ROAnsiString; const Date: DateTime): Breaks;
begin
Result := LoadData(0,EncodeDate(2020,1,1),ENcodeTime(1,1,1,1),ENcodeTime(1,1,1,1));
end;
Hi,
I’ve refactored most of my code and the error seems to have gone away. I’ll let you know if the problem continues.