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:
Tomas Janousek 2008-02-05 18:31:15 +01:00
parent 1534c8d728
commit 3a8ec6512b

View file

@ -559,21 +559,32 @@ BScreen::~BScreen() {
// we need to destroy it before we destroy workspaces // we need to destroy it before we destroy workspaces
m_workspacemenu.reset(0); m_workspacemenu.reset(0);
ExtraMenus::iterator mit = m_extramenus.begin(); if (m_extramenus.size()) {
ExtraMenus::iterator mit_end = m_extramenus.end(); // check whether extramenus are included in windowmenu
for (; mit != mit_end; ++mit) { // if not, we clean them ourselves
// we set them to NOT internal so that they will be deleted when the bool extramenus_in_windowmenu = false;
// menu is cleaned up. We can't delete them here because they are for (size_t i = 0, n = m_windowmenu->numberOfItems(); i < n; i++)
// still in the menu if (m_windowmenu->find(i)->submenu() == m_extramenus.begin()->second) {
// (They need to be internal for most of the time so that if we extramenus_in_windowmenu = true;
// rebuild the menu, then they won't be removed. break;
if (mit->second->parent() == 0) { }
// not attached to our windowmenu
// so we clean it up ExtraMenus::iterator mit = m_extramenus.begin();
delete mit->second; ExtraMenus::iterator mit_end = m_extramenus.end();
} else { for (; mit != mit_end; ++mit) {
// let the parent clean it up // we set them to NOT internal so that they will be deleted when the
mit->second->setInternalMenu(false); // menu is cleaned up. We can't delete them here because they are
// 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 (! extramenus_in_windowmenu) {
// not attached to our windowmenu
// so we clean it up
delete mit->second;
} else {
// let the parent clean it up
mit->second->setInternalMenu(false);
}
} }
} }