[Lazarus] animated splash screen for lengthy operation, works with windows, doesn't with linux

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Mar 27 15:40:25 CEST 2023


On Mon, 27 Mar 2023 14:40:26 +0200
Luca Olivetti via lazarus <lazarus at lists.lazarus-ide.org> wrote:

> El 27/3/23 a les 11:59, Luca Olivetti via lazarus ha escrit:
> 
> > [*] instead of opening the query I spawn a thread that opens it,
> > wait for it to finish while executing Application.ProcessMessages
> > and eventually reraise the exception that was generated inside the
> > thread.  
> 
> 
> Speaking of which, I encapsulated it in a procedure (TWaitForm is the 
> spash screen, Aproc is a procedure of object, TExecInThread simply
> calls AProc in its execute method):
> 
> procedure ExecWithSplash(AProc:TThreadProc);
> var wf:TWaitForm;
>      ut:TExecInThread;
> begin
>    Wf:=TWaitForm.Create(Application);
>    WF.Show;
>    ut:=TExecInThread.create(AProc);
>    while not ut.Finished
>      Application.ProcessMessages
>    wf.free;
>    if ut.FatalException<>nil then
>      raise(ut.FatalException);
>    ut.free;
> end;
> 
> 
> The problem here is, if AProc raises an exception, I cannot free the 
> thread causing a leak.

What does TExecInThread.Execute do?

> try
>    if ut.FatalException<>nil then
>      raise(ut.FatalException);
> finally
>    ut.free;
> end



Mattias



More information about the lazarus mailing list