vcl-styles-utils icon indicating copy to clipboard operation
vcl-styles-utils copied to clipboard

sugestion

Open cleberlr opened this issue 10 years ago • 3 comments

Sugestion of change in code of Unit Vcl.Styles.Utils.Menus from ` if (LParentMenu <> nil) and (LParentMenu.OwnerDraw) and (@LMenuItem.OnDrawItem <> nil) then begin LMenuItem.OnDrawItem(LMenuItem, Canvas, ItemRect, (isHot in State)); Exit; end;

if (LParentMenu <> nil) and (LParentMenu.OwnerDraw) and (LMenuItem <> nil) and (@LMenuItem.OnAdvancedDrawItem <> nil) then begin LOwnerDrawState := [];

if isHot in State then
  Include(LOwnerDrawState, odSelected);
if isDisabled in State then
  Include(LOwnerDrawState, odDisabled);
if isChecked in State then
  Include(LOwnerDrawState, odChecked);
if isDefault in State then
  Include(LOwnerDrawState, odDefault);

LMenuItem.OnAdvancedDrawItem(LMenuItem, Canvas, ItemRect, LOwnerDrawState);
Exit;

end; `

to ` if (LParentMenu <> nil) and (LMenuItem <> nil) then begin if (LParentMenu.OwnerDraw) and (@LMenuItem.OnDrawItem <> nil) then begin LMenuItem.OnDrawItem(LMenuItem, Canvas, ItemRect, (isHot in State)); Exit; end; end;

if (LParentMenu <> nil) and (LMenuItem <> nil) then begin if (LParentMenu.OwnerDraw) and (@LMenuItem.OnAdvancedDrawItem <> nil) then begin LOwnerDrawState := [];

  if isHot in State then
    Include(LOwnerDrawState, odSelected);
  if isDisabled in State then
    Include(LOwnerDrawState, odDisabled);
  if isChecked in State then
    Include(LOwnerDrawState, odChecked);
  if isDefault in State then
    Include(LOwnerDrawState, odDefault);

  LMenuItem.OnAdvancedDrawItem(LMenuItem, Canvas, ItemRect, LOwnerDrawState);
  Exit;
end;

end; `

cleberlr avatar Feb 27 '16 06:02 cleberlr

Hi, why is the reason for this suggestion? Any bug?

RRUZ avatar Feb 27 '16 16:02 RRUZ

Yes. I received an access violation message. LParentMenu was nil and the if clause try to access ownerdraw property.. Is better confirm if LParentMenu and LMenuItem is defined before access a property of them.

cleberlr avatar Feb 28 '16 04:02 cleberlr

I will check that. For suggestions related to code changes you can use the pull request option.

RRUZ avatar Feb 28 '16 16:02 RRUZ