[Lazarus] Dynamic Form Components - SynEdit Help Please...
mailinglists at collins-email.co.uk
Mon Oct 3 23:17:05 CEST 2016
I apologise for emailing but need a little bit of help please.
Creating form components dynamically is a new area of pascal programming
for me and I have become stuck. My application is supposed to be an
editor that can open multiple files for editing. I have a page control
and when opening a new file I add a page and place a synedit on the page
on it's own, into which the file is loaded. The loading works fine - I
create a stringlist, loadfromfile, then SetObjectProp(Component,
PropInfo['Lines'], StringList). StringList.Free works without error.
However, when I try to save the file the following code works, insomuch
the file is saved to disk, but the application crashes when trying to
free the stringlist (HTMLFile.Free) with the error 'Project raised
exception class 'External: SIGSEGV' At address 4201C3'. If I don't free
the stringlist, the application does not crash but I'm left with a
memory leak as indicated in my heap.trc file.
I have a feeling that HTMLFile is not actually a stringlist, I'm just
forcing it to be one here - HTMLFile := TStringList(GetObjectProp(Comp,
PropInfo, TStrings)); If that's the case, how can I get and/or save the
text from the dynamically created synedit. This has been puzzling me for
Many thanks for your help.
Using Lazarus 1.6, FPC 3.0.0, Linux x86_64 gtk2
procedure TMainForm.SaveSynEdit(ThisPage: Integer);
Comp : TComponent;
FileSaveDialog.Title:= 'Save File...';
FileSaveDialog.DefaultExt := 'html'; //default extension
FileSaveDialog.Filter := 'HTML source file|*.html';
FileSaveDialog.FileName:= Filename + '.html';
If FileSaveDialog.Execute then
Comp := PageControlEditor.ActivePage.Controls;
If Comp is TWinControl then
If IsPublishedProp(Comp, 'Lines') then
PropInfo := GetPropInfo(Comp, 'Lines', [tkClass]);
HTMLFile := TStringList(GetObjectProp(Comp, PropInfo, TStrings));
More information about the Lazarus