Fix a freed memory access in ~BScreen.
mit->second->parent() == 0 didn't do what it was supposed to. m_parent being zero does not imply that no pointer points to it. Signed-off-by: Tomas Janousek <tomi@nomi.cz>
This commit is contained in:
parent
1534c8d728
commit
3a8ec6512b
1 changed files with 26 additions and 15 deletions
|
@ -559,6 +559,16 @@ BScreen::~BScreen() {
|
|||
// we need to destroy it before we destroy workspaces
|
||||
m_workspacemenu.reset(0);
|
||||
|
||||
if (m_extramenus.size()) {
|
||||
// check whether extramenus are included in windowmenu
|
||||
// if not, we clean them ourselves
|
||||
bool extramenus_in_windowmenu = false;
|
||||
for (size_t i = 0, n = m_windowmenu->numberOfItems(); i < n; i++)
|
||||
if (m_windowmenu->find(i)->submenu() == m_extramenus.begin()->second) {
|
||||
extramenus_in_windowmenu = true;
|
||||
break;
|
||||
}
|
||||
|
||||
ExtraMenus::iterator mit = m_extramenus.begin();
|
||||
ExtraMenus::iterator mit_end = m_extramenus.end();
|
||||
for (; mit != mit_end; ++mit) {
|
||||
|
@ -567,7 +577,7 @@ BScreen::~BScreen() {
|
|||
// still in the menu
|
||||
// (They need to be internal for most of the time so that if we
|
||||
// rebuild the menu, then they won't be removed.
|
||||
if (mit->second->parent() == 0) {
|
||||
if (! extramenus_in_windowmenu) {
|
||||
// not attached to our windowmenu
|
||||
// so we clean it up
|
||||
delete mit->second;
|
||||
|
@ -576,6 +586,7 @@ BScreen::~BScreen() {
|
|||
mit->second->setInternalMenu(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeWorkspaceNames();
|
||||
using namespace FbTk::STLUtil;
|
||||
|
|
Loading…
Reference in a new issue