Stack Overflow in Cancel Dialog
I recently upgraded to 11.03 enterprise. Delphi 7. A report that used
to work is now throwing a stack overflow error. I can work around this
by setting ShowCancelDialog to False. However, I have a lot of reports
and am concerned that this is going to start showing up in others.
Here's the call stack:
TppForm.ShowModal <=== Stack Overflow here.
TppCustomCancelDialog.ppShowModal
TppProducer.PrintToPrinter
TppProducer.Print
TppReport.Print
function TppForm.ShowModal: Integer;
begin
{$IFDEF Delphi9}
if (PopupParent = nil) then
PopupParent := Screen.ActiveForm;
{$ELSE}
if HandleAllocated then
RecreateWnd;
{$ENDIF}
Result := inherited ShowModal; <=== Stack Overflow here.
end;
--
to work is now throwing a stack overflow error. I can work around this
by setting ShowCancelDialog to False. However, I have a lot of reports
and am concerned that this is going to start showing up in others.
Here's the call stack:
TppForm.ShowModal <=== Stack Overflow here.
TppCustomCancelDialog.ppShowModal
TppProducer.PrintToPrinter
TppProducer.Print
TppReport.Print
function TppForm.ShowModal: Integer;
begin
{$IFDEF Delphi9}
if (PopupParent = nil) then
PopupParent := Screen.ActiveForm;
{$ELSE}
if HandleAllocated then
RecreateWnd;
{$ENDIF}
Result := inherited ShowModal; <=== Stack Overflow here.
end;
--
This discussion has been closed.
Comments
report.
As another test you can try commenting out the code in TppForm.CreateParams.
We added some code to help manage the window layering of Modal Forms. The
code fixes the VCL issue of switching tasks in Windows and then switching
back and having the modal dialog displayed behind another window. If you
have code that free's the active window, then that could cause a stack fault
or AV.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
As a test try setting Report.ModalCancelDialog to False and then run
the report.
As another test you can try commenting out the code in
TppForm.CreateParams.
We added some code to help manage the window layering of Modal Forms.
The code fixes the VCL issue of switching tasks in Windows and then
switching back and having the modal dialog displayed behind another
window. If you have code that free's the active window, then that
could cause a stack fault or AV.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
<<
Setting modalCancelDialog to false does seem to correct the problem. I
do have code that frees the active window, in the sense that I set
Action:=caFree in the close event. The technique I use for reports is
to create the form, setup the report, print it, then close the form.
In some of my d7 apps I've been seeing chronic error messages like
"window has no scroll bars" in tform.create. I wonder if this is the
same issue, or perhaps related somehow.
Thanks for your help.
Jeremy
--
Have not heard of "window has no scroll bars" error. This is not an error
that anyone else has reported or that we can reproduce in our testing.
If you want to create a simple example that we can run here, you can send in
zip format to support@digital-metaphors.com and we can take a look at it.
Please use standard Delphi components and RB. Use the DBDemos data or dump
some data out to TClientDataSet.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
I have a similar problem and searching through Newsgroups I found your
suggestion to set ModalCancelDialog to False.
Initially I thought that it fixed my issues, but every so often I get a AV
on TppCustomCancelDialog.FormHideEvent;
It doesn't seem repeatable yet, and it only happens when I have a batch
process of multiple reports to be printed.
I am using Delphi7 and RB 11.04
Can you shed any light on this?
Many thanks
Justin
I tried the second solution (commenting out TppForm.CreateParams) and it is
more robust than setting ModalCancelDialog to False.
Unfortunately this means that printing a large batch of reports can not be
interrupted.
Will this change appear in 11.05?
Justin
D7 VCL is old and has many bugs that have since been fixed. VCL window
layering in D7 for modal dialogs is fundamentally designed wrong. We added
some code to manage it better. Our solution works as long as you don't free
the parent window while the report is executing.
To date no one has submitted any demos that show otherwise.
Later versions of the VCL have properties for explicitly managing the window
layering of modal dialogs.
I recommend updating to D2007 or D2009. They are far superior to D7.
As we move forward, we frequently find that new code that works in D2007 and
D2009 does not work in D6 and D7 - because of old VCL bugs. We are wasting
our resources by coding around old VCL bugs.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com