Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

AV Closing Custom Preview

edited June 2012 in General
Hi,

Using a Custom Preview Plugin, with a Preview.OnClose event. The OnClose
event Frees the Parent form of the cutom preview.

Randomly an AV is thrown with the attached call stack. Seems like (depending
on some kind of speed factor) FSearchPreview gets freed while
FSearchPreview.AfterPreviewActionPerformed is called.

Is it safe to assume that when aPreviewAction is paClose there's no need to
call AfterPreviewActionPerformed (and Inc ListenToControlChanges), thus
adding (aPreviewAction<>paClose) to the "if (FSearchPreview <> nil) then"
line?

RBuilder 14.05
Delphi 2010

Thanks

-Jack


date/time : 2012-06-27, 15:31:44, 677ms
operating system : Windows 7 x64 Service Pack 1 build 7601
system language : English
system up time : 6 hours 27 minutes
program up time : 1 minute 4 seconds
processors : 8x Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
physical memory : 5942/8149 MB (free/total)
free disk space : (C:) 209.46 GB
display mode : 1600x900, 32 bit
process id : $10d4
allocated memory : 93.50 MB
executable : MyApp.exe
compiled with : Delphi 2010
madExcept version : 3.0l
callstack crc : $00000000, $d24286f5, $d24286f5
exception number : 1
exception class : EAccessViolation
exception message : Access violation at address 00000000. Read of address
00000000.

main thread ($108c):
00000000 +000 ???
00b8778d +191 MyApp.exe ppPreview 705 +31
TppCustomPreview.PerformPreviewAction
00b89d60 +044 MyApp.exe ppPreview 1858 +14
TppPreview.ehToolbutton_Click
00a79390 +0a8 MyApp.exe ppTB2Item 1471 +22 TppTBCustomItem.Click
00a7926f +0b3 MyApp.exe ppTB2Item 1421 +27
TppTBCustomItem.ClickWndProc
004af0a0 +014 MyApp.exe Classes StdWndProc
764b7885 +00a USER32.dll DispatchMessageW
005944dd +11d MyApp.exe Forms
TApplication.ProcessMessage
00594522 +00a MyApp.exe Forms
TApplication.HandleMessage
0059484d +0c9 MyApp.exe Forms TApplication.Run
013c9fa1 +0bd MyApp.exe MyApp 119 +16 initialization
76393398 +010 kernel32.dll BaseThreadInitThunk

Comments

  • edited June 2012
    Hi Jack,

    Yes, upon my initial evaluation, it seems the ListenToControlChanges is
    relevant for preview actions other than closing.

    Freeing the parent form from the OnClose event of the previewer is a
    common task but frequently results in an AV due to timing issues. One
    workaround is to create a TTimer to be sure the Preview/Report has run
    it's destroy sequence in its entirety before freeing the parent.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.