Skip to content

Commit 048d701

Browse files
Merge pull request livecode#6935 from livecode/revert-6927-bugfix-21928
Revert "[[ Bug 21928 ]] Fix memory leak when using menu buttons"
2 parents 713f75a + a38ee2a commit 048d701

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

docs/notes/bugfix-21928.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

engine/src/button.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,23 +2860,11 @@ void MCButton::freemenu(Boolean force)
28602860
else
28612861
{
28622862
if (!MCStringIsEmpty(menustring) || force)
2863-
{
2864-
closemenu(False, True);
2865-
2866-
/* In this case the button owns the menu so after removing
2867-
* any references to it that might exist in the environment
2868-
* it must be explicitly deleted. */
2869-
MCStack *t_menu_ptr = menu.Get();
2870-
MCdispatcher->removepanel(t_menu_ptr);
2863+
{
2864+
closemenu(False, True);
2865+
MCdispatcher->removepanel(menu);
28712866
MCstacks->deleteaccelerator(this, NULL);
2872-
t_menu_ptr->removeneed(this);
2873-
t_menu_ptr->dodel();
2874-
2875-
/* It is safe to explicitly delete the menu stack here (rather
2876-
* than 'scheduledelete()') as menu stacks and their contents
2877-
* can never be on C stack as they don't contain script. */
2878-
delete t_menu_ptr;
2879-
2867+
menu->removeneed(this);
28802868
menu = nil;
28812869
}
28822870
}

engine/src/stack.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,13 +1485,6 @@ void MCStack::removereferences()
14851485
{
14861486
MCdispatcher->remove_transient_stack(this);
14871487
}
1488-
else if (!parent.IsValid() || parent->gettype() == CT_BUTTON)
1489-
{
1490-
/* If the parent is a button or non-existant then this is a
1491-
* menu-as-stack - registered with MCdispatcher as a panel. This code
1492-
* path is hit when performing dodel() on a menu-as-stack before it
1493-
* is explicitly deleted in MCButton::freemenu. */
1494-
}
14951488
else if (parent->gettype() == CT_STACK)
14961489
{
14971490
remove(parent.GetAs<MCStack>()->substacks);

0 commit comments

Comments
 (0)