Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Additional Controls/Action Bar Controls/TMainMenuActionBar    [ Add a report in this area ]  
Report #:  20278   Status: Open
Setting the WindowMenu property of TActionMainMenuBar should free internal objects that hold the MDI items
Project:  Delphi Build #:  10.0.2098.6408
Version:    10.0 Submitted By:   Jeremy North
Report Type:  Basic functionality failure Date Reported:  10/18/2005 7:38:26 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   233514
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description
I think the SetupWindowMenu procedure should free the FMDIActions and FMDISeparator objects and nil the FWindowMenuItem.

Alternative code provided in Workaround.
Steps to Reproduce:
This is the current code:

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    Ctrl :=  FindItemCaption(FWindowMenu);
    if Assigned(Ctrl) then
      FWindowMenuItem := Ctrl.ActionClient;
  end;
end;

This is one alternative:

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    Ctrl := FindItemCaption(FWindowMenu);
    if Assigned(Ctrl) then
      FWindowMenuItem := Ctrl.ActionClient
    else if FWindowMenu = '' then
    begin
      FWindowMenuItem := nil;
      FreeAndNil(FMDIActions);
      FreeAndNil(FMDISeparator);
    end;
  end;
end;

This is another :

(I prefer this one) - No use doing a FindItemCaption when the caption is blank.

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    if FWindowMenu = '' then
    begin
      FWindowMenuItem := nil;
      FreeAndNil(FMDIActions);
      FreeAndNil(FMDISeparator);
    end
    else
    begin
      Ctrl := FindItemCaption(FWindowMenu);
      if Assigned(Ctrl) then
        FWindowMenuItem := Ctrl.ActionClient
    end;
  end;
end;
Workarounds
This is the current code:

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    Ctrl :=  FindItemCaption(FWindowMenu);
    if Assigned(Ctrl) then
      FWindowMenuItem := Ctrl.ActionClient;
  end;
end;

This is one alternative:

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    Ctrl := FindItemCaption(FWindowMenu);
    if Assigned(Ctrl) then
      FWindowMenuItem := Ctrl.ActionClient
    else if FWindowMenu = '' then
    begin
      FWindowMenuItem := nil;
      FreeAndNil(FMDIActions);
      FreeAndNil(FMDISeparator);
    end;
  end;
end;

This is another :

(I prefer this one) - No use doing a FindItemCaption when the caption is blank.

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    if FWindowMenu = '' then
    begin
      FWindowMenuItem := nil;
      FreeAndNil(FMDIActions);
      FreeAndNil(FMDISeparator);
    end
    else
    begin
      Ctrl := FindItemCaption(FWindowMenu);
      if Assigned(Ctrl) then
        FWindowMenuItem := Ctrl.ActionClient
    end;
  end;
end;
Attachment
None
Comments

Albert de Weerd at 11/8/2012 10:53:13 AM -
I would prefer this solution:

procedure TCustomActionMainMenuBar.SetupWindowMenu;
var
  Ctrl: TCustomActionControl;
begin
  if Assigned(ActionClient) then
  begin
    if FWindowMenu = '' then
      FWindowMenuItem := nil
    else
    begin
      Ctrl :=  FindItemCaption(FWindowMenu);
      if Assigned(Ctrl) then
        FWindowMenuItem := Ctrl.ActionClient;
    end;
    RefreshMDIMenu;
  end;
end;

Server Response from: ETNACODE01