aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrepojohnray <8113421+repojohnray@users.noreply.github.com>2023-01-16 13:09:31 +0100
committerfuzzard <fuzzard@kodi.tv>2023-12-29 14:28:00 +1000
commit9ab625ee0ef37e7894b569bd20cf84c2d0cdf31e (patch)
treef2777b0b4768cf25ae62181826b482a1d767c531
parent27e729a75d3c86b81c44737adbf83603a22c4394 (diff)
[CGUIDialogContextMenu] fix memory leak
This memory leak is happening when a context menu is opened. This change addresses two issues: - Missing delete. - Group list not defined (the behavior is changed).
-rw-r--r--xbmc/dialogs/GUIDialogContextMenu.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/xbmc/dialogs/GUIDialogContextMenu.cpp b/xbmc/dialogs/GUIDialogContextMenu.cpp
index 76ceefc287..dcc9edec34 100644
--- a/xbmc/dialogs/GUIDialogContextMenu.cpp
+++ b/xbmc/dialogs/GUIDialogContextMenu.cpp
@@ -126,17 +126,17 @@ void CGUIDialogContextMenu::SetupButtons()
CGUIControlGroupList* pGroupList = dynamic_cast<CGUIControlGroupList *>(GetControl(GROUP_LIST));
// add our buttons
- for (unsigned int i = 0; i < m_buttons.size(); i++)
+ if (pGroupList)
{
- CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
- if (pButton)
- { // set the button's ID and position
- int id = BUTTON_START + i;
- pButton->SetID(id);
- pButton->SetVisible(true);
- pButton->SetLabel(m_buttons[i].second);
- if (pGroupList)
- {
+ for (unsigned int i = 0; i < m_buttons.size(); i++)
+ {
+ CGUIButtonControl* pButton = new CGUIButtonControl(*pButtonTemplate);
+ if (pButton)
+ { // set the button's ID and position
+ int id = BUTTON_START + i;
+ pButton->SetID(id);
+ pButton->SetVisible(true);
+ pButton->SetLabel(m_buttons[i].second);
pButton->SetPosition(pButtonTemplate->GetXPosition(), pButtonTemplate->GetYPosition());
// try inserting context buttons at position specified by template
// button, if template button is not in grouplist fallback to adding
@@ -591,7 +591,10 @@ void CGUIDialogContextMenu::OnDeinitWindow(int nextWindowID)
{
const CGUIControl *control = GetControl(BUTTON_START + i);
if (control)
+ {
RemoveControl(control);
+ delete control;
+ }
}
m_buttons.clear();