Recent

Author Topic: Store objects in TCustomSynEdit.fLines.Objects[]  (Read 3835 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Store objects in TCustomSynEdit.fLines.Objects[]
« on: January 17, 2017, 04:50:00 pm »
How go i get notified before deletion of lines in TCustomSynEdit.fLines?
I have stored own objects in TCustomSynEdit.fLines.Objects[] and i would like to destroy them before
the reference to them gets lost.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14393
  • Sensorship about opinions does not belong here.
Re: Store objects in TCustomSynEdit.fLines.Objects[]
« Reply #1 on: January 17, 2017, 05:17:08 pm »
Isn't that automatically? If FLines is a TStringlist then you can set Flines.OwnsObjects to true;
May or may not work I have not much experience with SynEdit.

Hm. Does not work, because:
Strange design: Objects property is introduced in TStrings, but OwnsObjects is introduced in TStringlist.
And FLines is a TStrings descendant.
So bad luck.. Or file a bug report against TStrings  O:-)
« Last Edit: January 17, 2017, 05:54:47 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9915
  • Debugger - SynEdit - and more
    • wiki
Re: Store objects in TCustomSynEdit.fLines.Objects[]
« Reply #2 on: January 17, 2017, 07:01:43 pm »
Unfortunately the only notification that SynEdit has, is after the line was deleted: senrLineCount

If it is edited by a user (via keystrokes), or if it is any "ecCommand" (SynEdit.CommandProcessor), then there is a "senrEditAction" for each line, that will tell delete all content from that line (but that does happen for other actions too).
And the "senrEditAction" is not sent for SynEdit.Lines.delete()

----------------
You can register a managed list like the fold highlighter does for ranges.

Search for RangeList in fold highlighter, create your own list (by subclassing the same base class)



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9915
  • Debugger - SynEdit - and more
    • wiki
Re: Store objects in TCustomSynEdit.fLines.Objects[]
« Reply #3 on: January 17, 2017, 07:03:14 pm »
Or write a patch, and submit on our bugtracker

So synedit lines get property OwnObjets, and destroy them if lines are cleared...

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Store objects in TCustomSynEdit.fLines.Objects[]
« Reply #4 on: January 18, 2017, 05:46:57 am »
You can register a managed list like the fold highlighter does for ranges.

Search for RangeList in fold highlighter, create your own list (by subclassing the same base class)
I have the same Problem with my descendant from fold highlighter: Not all of my objects are destroyed.

I think i will write a patch which adds OwnsObjects.
Thanks so far.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

 

TinyPortal © 2005-2018