sugestion
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; `
Hi, why is the reason for this suggestion? Any bug?
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.
I will check that. For suggestions related to code changes you can use the pull request option.