Skip to content

Conversation

@MattHeffron
Copy link
Contributor

This resolves #2306

Checking added to FNS: ADDMENU, CHECK/MENU/IMAGE, UPDATE/MENU/IMAGE, and MENU.

…e it.

Checking added to FNS: ADDMENU, CHECK/MENU/IMAGE, UPDATE/MENU/IMAGE, and MENU.
@MattHeffron MattHeffron self-assigned this Oct 3, 2025
@MattHeffron MattHeffron added the bug Something isn't working (as per documentation) label Oct 3, 2025
@rmkaplan
Copy link
Contributor

rmkaplan commented Oct 3, 2025

I think the menu arguments in the calls to ERROR shouldn't be quoted

@nbriggs
Copy link
Contributor

nbriggs commented Oct 3, 2025

Even prior to this change, the way it presents a problem with the ITEMS is:

image

and it's a "TYPE-MISMATCH" exception that is being reported, not an "INTERLISP-ERROR" that a call to ERROR will give you.

Copy link
Contributor

@pamoroso pamoroso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I successfully built this PR on Linux Mint 22.1 Cinnamon and the new MENU behavior seems to work with no issues. When the menu is not supplied or there are no items I now get warnings instead of break windows with division by 0 errors.

Copy link
Contributor

@pamoroso pamoroso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I successfully built this PR on Linux Mint 22.1 Cinnamon and the new MENU behavior seems to work with no issues. When the menu is not supplied or there are no items I now get warnings instead of break windows with division by 0 errors.

Copy link
Member

@masinter masinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a matter of taste, I suppose, but I would hate to see this style of error checking pervade the sources. We can't afford to add this kind of debugging tool support to prevent and diagnose errors that are rare and easily diagnosed when they do occur.

@masinter
Copy link
Member

masinter commented Oct 3, 2025

lets discuss ...

@rmkaplan
Copy link
Contributor

rmkaplan commented Oct 3, 2025 via email

@nbriggs
Copy link
Contributor

nbriggs commented Oct 3, 2025

I agree with Larry on this one. The UI code could have avoided creating an empty menu.

@rmkaplan
Copy link
Contributor

rmkaplan commented Oct 3, 2025 via email

@MattHeffron
Copy link
Contributor Author

An alternative approach would be to avoid the error, and instead put up a menu with a single dummy item ("No items").

My initial attempt, which I replaced before pushing it to GitHub, was to initialize the ITEMS field (in the record definition) with (LIST "*** Empty MENU!! ***"). I mentioned this in PR #2307.

This would break any code that built the list incrementally, and that assumed that ITEMS could be empty, and if so, created the LIST for the first item added, and used, e.g. NCONC1 to add to the existing list.
If the list was never really empty, then the "*** Empty MENU!! ***" entry would always be there.

The question is, when should the check for the empty ITEMS be made?
Since MENU, CHECK/MENU/IMAGE, and ADDMENU check the type of the MENU / ADDEDMENU argument at the beginning of the function body, it doesn't seem unreasonable to check there for conditions that will cause failure during/beneath these functions.

To modify the MENU ITEMS, at the time of the call, to note that it is empty, should also restore it after the call. This would be especially problematic with ADDMENU which leaves the menu visible beyond the temporal scope of the call.

@nbriggs
Copy link
Contributor

nbriggs commented Oct 4, 2025

I think we should not change it. It has worked this way since the MENU code was written. We're not seeing lots of undebuggable code as a result of this, and it should be the responsibility of the code that's constructing the menu to ensure that the items are properly set up before having the menu displayed. I think if we get to the point of being able to properly update the IRM (and thus DInfo) we could note that it is an error to cause a menu with no items to be displayed.

Copy link
Member

@masinter masinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the problem was, the changes here look fine today.

@MattHeffron MattHeffron added enhancement New feature or request and removed bug Something isn't working (as per documentation) labels Oct 6, 2025
@MattHeffron MattHeffron merged commit 43b11b2 into master Oct 6, 2025
@github-project-automation github-project-automation bot moved this to Done in system Oct 6, 2025
@MattHeffron MattHeffron deleted the mth51--Check-if-MENU-ITEMS-empty-before-using branch October 29, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

(MENU (create MENU)) divides by 0

6 participants