Recent

Author Topic: SynEdit MarkupManager RemoveMarkUp MarkupByClass  (Read 1619 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
SynEdit MarkupManager RemoveMarkUp MarkupByClass
« on: July 18, 2022, 02:22:54 am »
Why is this looping indefinitely ? Does not go to exception.
I guess It should remove type of TSynEditMarkupHighlightAll until none is left ?

assuming
Code: Pascal  [Select][+][-]
  1. MarkupManager.MarkupByClass[TSynEditMarkupHighlightAll]
  2.  
returns only one of n there.

How to do that ?



Code: Pascal  [Select][+][-]
  1.   while 1 = 1 do
  2.   begin
  3.   try
  4.  
  5.    SynEdit1.MarkupManager.RemoveMarkUp(SynEdit1.MarkupManager.MarkupByClass[TSynEditMarkupHighlightAll]);
  6.    except
  7.     on E: Exception do
  8.     begin
  9.      showmessage('foo');
  10.     end;
  11.    end;
  12.   end;      
  13.  
« Last Edit: July 18, 2022, 02:25:02 am by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9855
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit MarkupManager RemoveMarkUp MarkupByClass
« Reply #1 on: July 18, 2022, 11:28:19 am »
Why is this looping indefinitely ? Does not go to exception.

Why should it?
I haven't verified that, but I guess MarkupByClass eventually returns nil, and RemoveMarkup does nothing.

If so, you can check yourself if the value is nil.


You are aware, that once you done that, you must ensure not to call SynEdit.SetHighlightSearch (or related).
They have a pointer (dangling pointer, after you removed it) to the markup.

 

TinyPortal © 2005-2018