Recent

Author Topic: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile  (Read 2334 times)

matthius

  • Full Member
  • ***
  • Posts: 134
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Hello !

I want to create a LFM file from a registered form TF_FormDico.

But there is a SIGSEGV error on Writer.WriteDescendenton calling CreateLFMFile.

What can i do ?
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

speter

  • Full Member
  • ***
  • Posts: 209
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #1 on: May 16, 2021, 02:24:53 pm »
What can you do?

Easy, provide some code! :)

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

matthius

  • Full Member
  • ***
  • Posts: 134
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #2 on: May 16, 2021, 02:46:39 pm »
Here it is :

Code: Pascal  [Select][+][-]
  1. function fb_CreateForms ( var amif_Init : TIniFile; const as_destination : String ) : Boolean;
  2. var li_i : Integer;
  3.     LFileLFM : TFileStream;
  4.     aform : TF_XMLForm;
  5.     aformdico : TF_Formdico;
  6. Begin
  7.   FreeAndNil(gxdo_FichierXML);
  8.   if fb_CreateProject ( amif_Init, Application )
  9.   and fb_LoadXMLFile ( gxdo_FichierXML, fs_getLeonDir + gs_ProjectFile ) Then
  10.     Begin
  11.       Result := True;
  12.       // La fenêtre n'est peut-être pas encore complètement créée
  13.       gchar_DecimalSeparator := ',' ;
  14.       DecimalSeparator := gchar_DecimalSeparator ;
  15.       for li_i:=0 to High(ga_Functions) do
  16.        with ga_Functions [ li_i ] do
  17.         Begin
  18.          aform:=fxf_ExecuteAFonction ( li_i, true        );
  19.          aformdico := TF_FormDico.Create(Application);
  20.          aform.p_exchangeSources(aformdico);
  21.          if Assigned(aform)
  22.           Then
  23.            try
  24.              LFileLFM := TFileStream.Create(as_destination+Clep+'.lfm',fmCreate);
  25.              CreateLFMFile(aformdico,LFileLFM);
  26.            finally
  27.             LFileLFM.Destroy;
  28.             aform.Destroy;
  29.             aformdico.Destroy;
  30.            end;
  31.         end;
  32.     End
  33.    Else
  34.     Result := False;  
  35. end;  

The source is here :
https://sourceforge.net/p/xml-frames-vrad-lazarus/code/ci/default/tree/XMLToLFM/u_createproject.pas
https://sourceforge.net/p/xml-frames-vrad-lazarus/code/ci/8a78bcb3267b78a2a4b71e99bcb129c9505b3345/tree/demos/weo_firebird/builder.lpi
« Last Edit: May 16, 2021, 03:24:23 pm by matthius »
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

jamie

  • Hero Member
  • *****
  • Posts: 4563
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #3 on: May 16, 2021, 05:34:03 pm »
maybe what you want is to use a TApplicationProperties, its on the additional tab..

with that you can specify the properties to save or load and the file to write or read it to..

Also on the MISC tab you have TXMLPropStorage that can do the same..

The only true wisdom is knowing you know nothing

matthius

  • Full Member
  • ***
  • Posts: 134
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #4 on: May 17, 2021, 11:26:40 am »
I want to create a lfm file with every porperties saved. I do not want to select some properties because there are a lot to save.

What is the method which save properties on TApplicationProperties ?
« Last Edit: May 17, 2021, 11:29:13 am by matthius »
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

lucamar

  • Hero Member
  • *****
  • Posts: 4009
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #5 on: May 17, 2021, 12:46:15 pm »
TApplicationProperties is not meant to save/load properties; for that one should rather use the form's SessionProperties along with any of the TFormPropertyStorage descendants (TIniPropStorage, TXMLPropStorage, etc.), which have convenient events which are called before/after saving/restoring and allow you to store any additional value you might want.

An example, from one of my own apps, which loads a Memo after reading the file name from a TXMLPropStorage instance on application restart:
Code: Pascal  [Select][+][-]
  1. procedure TMain.RestoreProperties(Sender: TObject);
  2. begin
  3.   CurrentFile := XMLStore.ReadString('File', '');
  4.   if CurrentFile = FDefaultFile then
  5.     CurrentFile := '';
  6.   if (CurrentFile <> '') and FileExists(CurrentFile) then
  7.     Memo.ReadFromFile(CurrentFile)
  8.   else if FileExists(FDefaultFile) then begin
  9.     Memo.ReadFromFile(FDefaultFile);
  10.     Memo.Filename := '';
  11.   end;
  12.   Timer.Enabled := itOptionsTimer.Checked;
  13. end;
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

matthius

  • Full Member
  • ***
  • Posts: 134
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #6 on: May 17, 2021, 01:52:12 pm »
But i want to create a LFM file.

Lazarus uses Writer.WriteDescendent in CustomFormEditor.

Why does it work ?
« Last Edit: May 17, 2021, 01:56:15 pm by matthius »
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7149
  • Debugger - SynEdit - and more
    • wiki
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #7 on: May 17, 2021, 02:15:50 pm »
Maybe it is something in your data? (inheritance of TF_XMLForm? inheritance of other classes used within? dangling pointer? ....)

Can you provide a "cut down" simple project, that we can open in our IDE and run, and that will have the crash?


I understand you want an lfm.
And even if you changed your mind, it might be helpful to first understand what went wrong. So following this up should stay on the table.

But I thought I might yet point you to an alternative, that may be of interest.
   TRttiXMLConfig  in unit Laz2_XMLCfg

This will write published properties to an xml file. (It is what the IDE uses for it's own config).

matthius

  • Full Member
  • ***
  • Posts: 134
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #8 on: May 17, 2021, 02:56:37 pm »
It crashes on a form registered with RegisterCustomForm.

I will do with it.
« Last Edit: May 17, 2021, 03:04:23 pm by matthius »
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7149
  • Debugger - SynEdit - and more
    • wiki
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #9 on: May 17, 2021, 03:30:07 pm »
You mean RegisterCustomForm in unit WSForms?
That is odd. That is not Streaming related.

Is your project a GUI application?

If you use the class TForm (or TCustomForm) then you need to include the unit Interfaces (as will happen for any GUI app, but not for "simple program".)
If you do not need to display the form, there is a "nogui" widgetset, that can be chosen in "project options"

Though, not using interfaces would get a compile time error (afaik). So a crash means something else....

matthius

  • Full Member
  • ***
  • Posts: 134
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #10 on: May 18, 2021, 05:09:49 pm »
I cannot register my form. But i want.
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7149
  • Debugger - SynEdit - and more
    • wiki
Re: Writer.WriteDescendent SIGSEGV error on calling CreateLFMFile
« Reply #11 on: May 18, 2021, 05:41:44 pm »
I cannot register my form. But i want.
What are you trying to do?

RegisterCustomForm in unit WSForms does not register a/your custom form.

It does register TCustomForm (which is the base class of all forms). And this is done once by the LCL.
It basically links the LCL class to the win32/gtk/cocoa/.... specific code in the backend.


Maybe you were looking for something like RegisterClass(es) or RegisterComponents?
Those are streaming related.

 

TinyPortal © 2005-2018