ShowPopupForm will sometimes throw an exception (new in AC14,33)

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #62379
    HeDiBo
    Participant

    Sometimes a ShowPopupForm will give an exception:

    This is the trace leading to the exception:

    My procedure:
    
    procedure TfrCompetition.btnAddPoolClick(Sender: TObject);
    var
       p: TPoint;
    begin
       btnAddPool.Enabled := False;
       if not Assigned(frmAddPool2Comp) then frmAddPool2Comp := TfrmAddPool2Comp.Create(Self);
       p := btnAddPool.ClientToScreen(Point(0, btnAddPool.Height));
       ShowPopupForm(frmAddPool2Comp, p);  // Will throw exception
    end;
    
    acPopupController: lines 130-134
    procedure ShowPopupForm(AForm: TForm; ALeftTop: TPoint; Animated: boolean = True);
    begin
      GetIntController.KillAllForms(AForm);   // <<< Throws exception
      acIntController.ShowFormPos(AForm, ALeftTop, Animated);
    end;
    
    acPopupController: lines 137-146:
    procedure TsPopupController.KillAllForms(ExceptChild: TForm);
    var
      i: integer;
      ParentForm: TForm;
      ClosedAll: boolean;
    begin
      if ExceptChild <> nil then
        ParentForm := TForm(GetOwnerForm(ExceptChild.Owner))  // <<< Throws exception
      else
        ParentForm := nil;
    
    sVclUtils: lines 3146-3175:
    function GetOwnerForm(const Component: TComponent): TCustomForm;
    var
      c: TComponent;
    begin
      Result := nil;
      c := Component;             // <<< Component is an invalid address ($80808080)
      while Assigned(c) and not (c is TCustomForm) do
        c := c.Owner;
    
      if c is TCustomForm then
        Result := TCustomForm(c);
    end;
    

    Apparently the ExceptChild.Owner may be freed without being nil.

    #62440
    Support
    Keymaster

    Apparently the ExceptChild.Owner may be freed without being nil.

    Yes, looks like that. But I can’t imagine when owner may be destroyed here.
    Is it possible to make a test-app with such problem?

    #62442
    HeDiBo
    Participant

    Yes, looks like that. But I can’t imagine when owner may be destroyed here.
    Is it possible to make a test-app with such problem?

    I’ll have another look at it tomorrow.

    #62480
    HeDiBo
    Participant

    Found the bug.
    My project consists of a large number of TFrames, placed on pages of a giant TsPageControl. Some of these frames may show pupup windows. If these windows close, they set the Action to caFree and set there form variable to nil.
    One of the popup windows did not set the form variable to nil. Causing the problem.
    I still think it’s a bug in AC. Setting Action to caFree should be enough.

    #62766
    Support
    Keymaster

    Hello!
    The package doesn’t use these variables, they are not accessible in units of the package.
    If I understand you correctly.
    Can you help me to repeat the error, please? Is it possible in a separate demo-app?

    #62961
    HeDiBo
    Participant

    Sorry Serge,

    It was my own stupid mistake 😳

    #68198
    HeDiBo
    Participant

    This one can be closed.
    Previously I could close topics myself. Is there some way now to do that? That is, can I add the tag [Resolved] myself?

    #68217
    Support
    Keymaster

    Topic may be closed by author or by admin in the his first message.

    Attachments:
    You must be logged in to view attached files.
    #68224
    HeDiBo
    Participant

    I don’t see this menu line in my first post.
    It only says:

    October 13, 2019 at 1:49 pm REPLY | QUOTE #62379

    • This reply was modified 4 years, 11 months ago by HeDiBo.
    • This reply was modified 4 years, 11 months ago by HeDiBo.
    #68276
    HeDiBo
    Participant

    Any progress on letting authors close their own topics?

    #68286
    Support
    Keymaster

    No, sorry. Can’t find how to make it in the WP still.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.