[fpc-pascal] Re: Fpc Access Violation if AppConfigDir doesn't exist.

Michael Van Canneyt michael at freepascal.org
Tue Feb 12 14:02:04 CET 2013



On Tue, 12 Feb 2013, Mattias Gaertner wrote:

>
> Giuliano Colla <giuliano.colla at fastwebnet.it> hat am 12. Februar 2013 um 13:29
> geschrieben:
>> [...]
>> Why FormClose doesn't close the form in presence of an error (handled by
>> a try..finally) when writing the ini file?
>> Launching from command line, you have the same behavior, and an
>> additional information when you select Cancel:
>>
>> WARNING: TLCLComponent.Destroy with LCLRefCount>0. Hint: Maybe the component
>> is processing an event?
>>
>>
>> Try..except situation, from IDE and Debugger.
>> Press the Close button. Debugger Notification. Pressing Continue my
>> message dialog is shown. Pressing OK on my dialog the form is closed and
>> the program is terminated.
>> Launching from command line, no console messages.
>>
>> My conclusion is that one can't properly handle INI files with just a
>> try..finally construct, as all examples show, because a possible error
>> will propagate outside the construct, with unpredictable effects (in
>> this case the FormClose procedure doesn't properly complete).
>
> The LCL has a default exception handler, so that the application notifies the
> user, that the application has a bug instead of simply crashing and vanishing
> silently.
> The programmr is reponsible to handle exceptions, show the user error messages
> and give the user choices (e.g. ignore, retry).
> BTW, the Ini.Free writes to disk, so it needs the try..except, the WriteValue
> calls do not need the try..except.

That depends. 
if you disabled write caching, every write call will update the file.

Michael.



More information about the fpc-pascal mailing list