Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 4e7a7df

Browse files
committed
[[ Bug 20961 ]] Reset the menu object when swapping menus
This patch resets `MCmenuobjectptr` to `null` when changing from one menu to another. This allows `openmenu` to set it to the new button and and for `closemenu` to correctly set it to `null`. Previously `MCmenuobjectptr` was left referring to the first button and therefore not cleared on `closemenu` and leaving the button in an unable to delete state.
1 parent a8f7126 commit 4e7a7df

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/notes/bugfix-20961.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Clear the menu object when moving from one menu to another

engine/src/button.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,10 @@ Boolean MCButton::mfocus(int2 x, int2 y)
911911
bptr->message_with_args(MCM_mouse_down, menubutton);
912912
MCRedrawUnlockScreen();
913913
bptr->findmenu();
914+
if (menudepth == 0)
915+
{
916+
MCmenuobjectptr = nullptr;
917+
}
914918
bptr->openmenu(False);
915919
return True;
916920
}

0 commit comments

Comments
 (0)