Lazarus with Briefcase

In my Lazarus Application i am tying to use the briefcase-Mode. I adapted the example and when i start the App without a app.briefcase Folder the Tables are downloaded. If i start the App again, i get a Memory Error…

procedure TDM.LoadData;
var
  lbriefcaseName: string;
  lbriefcase: TDAFolderBriefcase;
begin
  AddToLog('Initial loading...');
  AddToLog('Looking for the local briefcase first...');
  lbriefcaseName := GetBriefcaseFileName;
  AddToLog('Briefcase: '+ lbriefcaseName);

  if not DirectoryExists(lbriefcaseName) then
  begin
    AddToLog('No briefcase found. Downloading fresh data...');
    LoadFromServer;
  end
  else begin
    AddToLog('Briefcase has been found.'); 
    lbriefcase:= TDAFolderBriefcase.Create(lbriefcaseName,True,True); ///// The Error shows in this Line
    if ValidateBriefcase(lbriefcase) then begin
      GetTablesFromBriefcase(lbriefcase);
    end
    else begin
      AddToLog('Clearing briefcase and downloading fresh data...');
      LoadFromServer;
    end
  end;
  AddToLog('Data is ready.')
end;     

I use the newest Version and Lazarus 1.6

RemObjects Remoting SDK for Delphi - 9.1.100.1271.exe [Branch: gamma] — Wed, Oct 26, 2016

Any Help on this Topic?

Hello

Could you send to support@ the briefcase that causes this issue?

Thanks in advance

I can’t reproduce any problems with your briefcase:

I’ve used lazarus-1.6.0-fpc-3.0.0-win64.exe and this code:

procedure TForm1.Button1Click(Sender: TObject);
var
  lbriefcaseName: string;
  lbriefcase: TDAFolderBriefcase;
  i: integer;
begin
  AddToLog('Initial loading...');
  AddToLog('Looking for the local briefcase first...');
  lbriefcaseName := '..\Gideons.briefcase';
  AddToLog('Briefcase: '+ lbriefcaseName);

  try
    lbriefcase:= TDAFolderBriefcase.Create(lbriefcaseName,True,True);
    for i:=0 to lbriefcase.TableCount-1 do
      AddToLog('tables: '+ lbriefcase.TableName[i]);
  finally
    lbriefcase.Free;
  end;
end;
1 Like

For me it look like there is a Problem, as soon there is a filter on the Server:

SELECT 	
	*
FROM 
	`HOTEL` 
WHERE 
	{WHERE} 
AND {filter}

Tables with no {filter} work fine.

This Table Type show the Error:

This Table works fine:

Tested with quite some Tabeles, alwas with the same Error.

filter macro isn’t defined so your table is opened in DASM as

SELECT 
            * 
FROM
          `HOTEL`
WHERE
           (1=1)
AND filter

also this table won’t work in run-time unless you defined filter macro

This Problem is real strange. // Checkt again for the Tables and you are right it has nothing to do with the Filter
If i just “load” 2 tables i get Also the Error ( always only the 2end Time i start up the App ) but i can work with the Briefcase and the Reports are relay fast compare to the Online Version…
Any hints how to get to the bottom of this Problem?

Just found the Problem…
If i compile my App with Lazarus 32 Bit there is the Error, with Lazarus 64 it works…
I need my Application also as 32 bit

can you create a simple testcase that reproduces your problem, pls?
you can send it to support@ or attach it here

Did send you a sample Project.

Thanks, logged as bugs://76633

I reproduced this problem.
I can recommend to not use briefcases until this case will be fixed because you can lose some data

until this case will be fixed because you can lose some data

Is this only the case if data are entred on the client-side?
Is the Data loss Problem limited to the 32-Bit Version?

briefcase data is stored incorrectly for Lazarus if datWideString is used. this is related to recent fix that Lazarus uses UTF8 strings instead of pure Unicode strings.

bugs://76633 got closed with status fixed.

pls update uDABin2DataStreamer.pas as

procedure TDABin2DataStreamer.InternalDoWriteDataset_NonDataset_without_events(
...
                {$IFDEF FPC_UTF16_as_UTF8}
                SetString(s, PAnsiChar(fldInfo[i].Data), fldInfo[i].DataSize);
                ws := UTF8ToString(s);
                Bin2_WriteIntegerToStream(Data, Length(ws)*SizeOf(Widechar));
                Data.Write(Pointer(ws)^, Length(ws)*SizeOf(Widechar));
                {$ELSE}
...

Logged as bugs://i64485.

bugs://i64485 was closed as fixed.