Home End User

AV with reportexplorer hosted on a form in RB7 when closing app.

edited September 2002 in End User
Hi,

I have a form on witch i place the reportexplorer-form.
This form is created at runtime by the MainForm.All needed components are
present on this form, except the tables.

Code:

function TfrmRbExplorer.ShowExplorer: Boolean;
begin
result := true;
if Assigned(ReportExplorer.Form) then
Exit;
result := ReportExplorer.Execute;
if result then
begin
ReportExplorer.Form.Parent := Self;
ReportExplorer.Form.BorderIcons := [];
ReportExplorer.Form.BorderStyle := bsNone;
ReportExplorer.Form.Align := alClient;
end;
end;

When closing the app.(Mainform) i get an AV.
This only happens with rb7, rb6.03 does not do this to me !!!!
This occures when freeing the form whitch contains the explorerform.
I noticed that the Owner of the explorerform is set to Application.
So one of the first things that gets freed is the explorerform.
I tried this:

if result then
begin
Application.RemoveComponent(ReportExplorer.Form);
Self.InsertComponent(ReportExplorer.Form);
ReportExplorer.Form.Parent := Self;
.........

Now the Aplication object does not free the explorerform anymore and the
responsebility
of freeing it is shifted to the form it self.
This also didnt work.

After debuging i found that when the DESIGNER gets freed the AV happens.
In the destructor of TppDesigner the FDesignerWindow.Free gets called.
In the destructor of TppDesignerWindow the FToolbarManager.Free gets called.
This will cause the AV !!
Notice that i didnt even open a designer window !!
I just start the app, show the explorer , and close it.

I have tried a couple of workarounds but i can't get rid of this AV.

Please help me out , beacause this is becoming a showstopper for the rb7
version.

TIA,
Nico.

Comments

  • edited September 2002
    You can use the OnCreate of the report explorer form as shown in this demo
    to show the explorer form in another form. I tried parenting it to a panel
    and also a form and it works in this demo:

    http://www.digital-metaphors.com/tips/ReportExplorerAsMDIChild.zip


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Thanks Jim,

    I will try this.

    Best regards,
    Nico.
  • edited September 2002
    Hi Jim,

    The Demo works without any problems.

    I have found what is causing the problem.
    In my App. i ceep a objectlist with forms that are parented on a panel of
    the MainForm.
    This objectlist is created and destroyd with te initialization &
    finalization of that unit.
    To prevent that the MainForm will destroy the hosted forms on its panel it
    will remove
    the ownership of the forms from the panel.
    This takes place in the destructor of the MainForm:

    for lCntr := pnlFormHolder.ControlCount -1 downto 0 do
    begin
    if pnlFormHolder.Controls[lCntr] is TfrmBasePanel then
    pnlFormHolder.RemoveControl(pnlFormHolder.Controls[lCntr]);
    end;
    inherited;

    TfrmBasepanel is my superclass for the forms on the panel.
    pnlFormHolder is the panel on whitch the forms are showed.

    This code will prevent that when the MainForm is destroyed my forms are also
    destroyed so my pointers in the objectlist are still valid.
    This works fine for all of my forms except the form whitch contains the RB
    explorer component and other needed components for the rbExplorer.

    As soon as this form is "removed" from the panel some rb objects get's freed
    whitch will result in a AV
    when the complete form is freed.(due freeing the objectlist)
    I didnt test "moving" the ownership of the form to an other object and
    kepping the app. alive, but i think this will also cause a AV when trying to
    use the explorer afterwards.


    Hope this is usefull to you,
    Nico.






  • edited September 2002
    Can you break your approach down into a simple example that we can run?
    Send it to support@digital-metaphors.com


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Hi Jim,


    I have created a simple app. that will reproduce the AV.
    It s on its way to support now,

    Cheers,
    Nico.
This discussion has been closed.