Recent

Author Topic: [SOLVED] LazIDEIntf handlers usage  (Read 477 times)

Dimitrios Chr. Ioannidis

  • Full Member
  • ***
  • Posts: 123
    • Nephelae
[SOLVED] LazIDEIntf handlers usage
« on: April 10, 2020, 01:44:44 pm »
Hi,

  can someone point me to the right direction ( example, documentation .. ) regarding the AddHandlerOnRunDebug and family usage ?

  I want to execute something without stopping the rundebug flow. I tried with Handled = false, Handled = True, various TModalResult values for result and various combinations with no success.

 After reading the sources I implement the following workaround . In the called function I remove it's self from the handlers list and call DoCallRunDebug again . Fortunately because I need to execute something when the IDE finishes running / debugging in the RunFinished handler I add the previous removed handler function back again to be fired in the next run, rundebug cycle.

i.e.
Code: Pascal  [Select][+][-]
  1.  
  2.   LazarusIDE.AddHandlerOnRunDebug(@LSW.RunHandler);
  3.   LazarusIDE.AddHandlerOnRunWithoutDebugInit(@LSW.RunNoDebugHandler);
  4.   LazarusIDE.AddHandlerOnRunFinished(@LSW.StopHandler, True);
  5.  

Code: Pascal  [Select][+][-]
  1. function TLSW.RunHandler(Sender: TObject; var Handled: boolean): TModalResult;
  2. begin
  3.   DoClose;
  4.   FRWD := True;
  5.   LazarusIDE.RemoveHandlerOnRunDebug(@Self.RunHandler);
  6.   LazarusIDE.DoCallRunDebug(Handled);
  7. end;
  8.  
  9. function TLSW.RunNoDebugHandler(Sender: TObject; var Handled: boolean): TModalResult;
  10. begin
  11.   DoClose;
  12.   FRWD := False;
  13.   LazarusIDE.RemoveHandlerOnRunWithoutDebugInit(@Self.RunNoDebugHandler);
  14.   LazarusIDE.DoCallRunWithoutDebugInit(Handled);
  15. end;
  16.  
  17. procedure TLSW.StopHandler(Sender: TObject);
  18. begin
  19.   DoOpen;
  20.   if FRWD then
  21.     LazarusIDE.AddHandlerOnRunDebug(@Self.RunHandler)
  22.   else
  23.     LazarusIDE.AddHandlerOnRunWithoutDebugInit(@Self.RunNoDebugHandler);
  24. end;    
  25.  

I have the feeling that maybe this is not the correct usage so, I'll appreciate any hint ...

regards,
« Last Edit: April 10, 2020, 07:47:43 pm by Dimitrios Chr. Ioannidis »
Dimitrios Chr. Ioannidis
http://www.nephelae.eu

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6288
    • wiki
Re: LazIDEIntf handlers usage
« Reply #1 on: April 10, 2020, 02:23:27 pm »
First of all: I have no idea.

You also do not say what actually goes wrong.

I guess the only answer will be in the IDE code

TLazIDEInterface.DoCallModalHandledHandler(
suggests, that "Handled := False" should be fine.
If handled is false, result will be set in that procedure (mrOk)

For all else find the calling functions, such as (main.pp): TMainIDE.DoRunProject calling DoCallRunDebug.

Dimitrios Chr. Ioannidis

  • Full Member
  • ***
  • Posts: 123
    • Nephelae
Re: LazIDEIntf handlers usage
« Reply #2 on: April 10, 2020, 02:34:18 pm »

< snip >

You also do not say what actually goes wrong.

< snip >


You're right, sorry, I missed writing the actual problem. The problem is that it seems that the IDE is stopping at my handler. Does not continue. I tried also the first boolean option with no success also.


< snip >

TLazIDEInterface.DoCallModalHandledHandler(
suggests, that "Handled := False" should be fine.
If handled is false, result will be set in that procedure (mrOk)

< snip >


Yes this is what i read at the sources also, but it's not working for me . I'll take a look again ...

BTW, i'm using laz trunk r62811.

regards,
Dimitrios Chr. Ioannidis
http://www.nephelae.eu

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6288
    • wiki
Re: LazIDEIntf handlers usage
« Reply #3 on: April 10, 2020, 03:17:14 pm »
You are aware that you can easily debug the IDE itself?

Assuming write access to the install folder. Otherwise the rebuild IDE is stored in the primary conf dir.

Open project ide/lazarus.lpi
You need to rebuild via the tools menu (and make sure the new build is NOT named lazarus.new.exe (happens on win, if the file is locked)

Set your breakpoints.
Then run with F9.

And you can then start debugging, within the debugged IDE....

Dimitrios Chr. Ioannidis

  • Full Member
  • ***
  • Posts: 123
    • Nephelae
Re: LazIDEIntf handlers usage
« Reply #4 on: April 10, 2020, 07:47:26 pm »
Hi,

  it took me a while to understand that if you use a docked form in a package, the show and hide events doesn't fire . I'm not familiar with that part of Lazarus and the result was a runaway exception that blocked the flow but somehow it was suppressed .

  The handlers works as expected . No need for double calls, just a lot of try...except..end blocks to guard the flow.

regards, 
« Last Edit: April 10, 2020, 07:50:12 pm by Dimitrios Chr. Ioannidis »
Dimitrios Chr. Ioannidis
http://www.nephelae.eu

Mathias

  • New Member
  • *
  • Posts: 41
Re: [SOLVED] LazIDEIntf handlers usage
« Reply #5 on: April 17, 2020, 05:08:02 pm »
Do you deliberately have no
Code: Pascal  [Select][+][-]
  1. LSE := TLSW.Create
anywhere ?

Dimitrios Chr. Ioannidis

  • Full Member
  • ***
  • Posts: 123
    • Nephelae
Re: [SOLVED] LazIDEIntf handlers usage
« Reply #6 on: April 17, 2020, 05:13:28 pm »
Hi,

Do you deliberately have no
Code: Pascal  [Select][+][-]
  1. LSE := TLSW.Create
anywhere ?

the code posted are code fragments from https://github.com/dioannidis/lazserialmonitor .

There in ulswregister.pas unit exists :

Code: Pascal  [Select][+][-]
  1. initialization
  2.   LSW := TLSW.Create;
  3.  
  4. finalization
  5.   FreeAndNil(LSW);

regards,
Dimitrios Chr. Ioannidis
http://www.nephelae.eu

 

TinyPortal © 2005-2018