[Lazarus] animated splash screen for lengthy operation, works with windows, doesn't with linux
Luca Olivetti
luca at wetron.es
Mon Mar 27 17:26:01 CEST 2023
El 27/3/23 a les 16:50, Michael Van Canneyt ha escrit:
>>>
>>> Ehm. In case of an exception, ut will never be freed ?
>>
>> That's what I said.
>> I was looking for a way to free it *and* raise the exception in the
>> context of the main thread.
>> If I move the ut.free before the raise, the exception has already been
>> freed and it's invalid, causing a sigsev, if I enclose it in a
>> try..finally the exception handler will be called after the finally
>> has freed the thread (and the exception, so it's the same problem).
>
> Normally, I'd do
>
> Raise
> Exception(ut.fatalexception.classtype).Create(ut.fatalexception.message);
Actually I'd have to first create the exception, then free ut, then
raise the exception (keep in mind that FatalException is a TObject and
it isn't necessarily of class Exception), otherwise a direct raise as
you wrote would not free ut.
MyException:=nil;
if ut.FatalException<>nil then
begin
if ut.FatalException is Exception then
MyException:=Exception(ut.FatalException).Create(Exception(ut.FatalException).message)
else
MyException:=Exception.create(ut.FatalException.ClassName);
end;
ut.free;
if MyException<>nil then
raise MyException;
But it still doesn't work, since this way MyException is a copy of
FatalException (i.e. it's no different than
MyException:=Exception(ut.FatalExcaption), so freeing ut, which in turn
frees ut.FatalException, makes it invalid and causes a sigsev.
The best I could do is store the exception message and raise a new one.
Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007
More information about the lazarus
mailing list