Page 1 of 1

Error on termination of an application using TRichView

Posted: Tue Oct 09, 2007 9:01 am
by Eugene Kruglov
Hi, all,

Does anyone know what may happen in application that uses an array of dynamically created/destroyed TRichViewEdits? While a program is running, everything is OK but on termination the following error occurs (the information is derived using JCL Debugger). Also used are TRvaControlPanel, TRichViewActions, TRVPrint.

This error is transient, its conditions are unknown :(

09.10.2007 14:45:15 Exception EAccessViolation occured at address 00000000
Message: Access violation at address 00000000. Read of address 00000000
Call stack:
[00548247] CRVData.TCustomRVData.Clear (Line 1693, "CRVData.pas")
[0051E415] CRVFData.TCustomRVFormattedData.Clear (Line 774, "CRVFData.pas")

With hope, Eugene

Posted: Tue Oct 09, 2007 12:50 pm
by Sergey Tkachenko
A guess, may be stupid: may you create RichViews dynamically passing some form as an Owner parameter. When this form is freed, it frees all its controls, including these RichViews. When, in some other place, you free all RichViews in your array, and the error occurs.

Posted: Wed Oct 10, 2007 3:31 am
by shmp
Just a suggestion. When an item (especially a component) has been removed without formatting TRichView, AV usually occurs. On form destroy event, I put rv.clear and rv.format. It did not cause AV anymore.

Hope this may come in handy.

Posted: Wed Oct 10, 2007 7:24 am
by Sergey Tkachenko
When an item (especially a component) has been removed without formatting TRichView, AV usually occurs
It should not happen.

Posted: Wed Oct 10, 2007 10:44 am
by Eugene Kruglov
shmp wrote:On form destroy event, I put rv.clear and rv.format. It did not cause AV anymore.
I did it, but the error persists... Then I've added the try.. except block in 'CRVData.pas' in place where the error comes from, and all was finished. The benefit from doing this is elimination of annoying OS's window which offers to send to Microsoft a report about an error :) But this error however occurs, it is visible in application's log file. What's up, I don't know.

Posted: Wed Oct 10, 2007 11:30 am
by Sergey Tkachenko
Place a breakpoint in TRichView.Destroy. Calculate how many times it is called (may be it is called twice for the same TRichView)

Posted: Thu Oct 11, 2007 2:49 am
by shmp
My simple guess is that an item (notably a component) has an event created for it. If the item is removed but the event is still triggered, the AV is unavoidable. The clear and format doesn't help anyway. It is only a guess and the problem could be other things.

Posted: Thu Oct 11, 2007 8:21 am
by Sergey Tkachenko
Yes, I agree, it is highly possible that this error occurs because of code in some event. Error occurs when accessing some component on form that is already destroyed.

Posted: Thu Oct 11, 2007 11:32 am
by Eugene Kruglov
I will try your suggestions, then report... Thank you for attention!