aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Screen.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 400e7e2..16f39b1 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -559,21 +559,32 @@ BScreen::~BScreen() {
559 // we need to destroy it before we destroy workspaces 559 // we need to destroy it before we destroy workspaces
560 m_workspacemenu.reset(0); 560 m_workspacemenu.reset(0);
561 561
562 ExtraMenus::iterator mit = m_extramenus.begin(); 562 if (m_extramenus.size()) {
563 ExtraMenus::iterator mit_end = m_extramenus.end(); 563 // check whether extramenus are included in windowmenu
564 for (; mit != mit_end; ++mit) { 564 // if not, we clean them ourselves
565 // we set them to NOT internal so that they will be deleted when the 565 bool extramenus_in_windowmenu = false;
566 // menu is cleaned up. We can't delete them here because they are 566 for (size_t i = 0, n = m_windowmenu->numberOfItems(); i < n; i++)
567 // still in the menu 567 if (m_windowmenu->find(i)->submenu() == m_extramenus.begin()->second) {
568 // (They need to be internal for most of the time so that if we 568 extramenus_in_windowmenu = true;
569 // rebuild the menu, then they won't be removed. 569 break;
570 if (mit->second->parent() == 0) { 570 }
571 // not attached to our windowmenu 571
572 // so we clean it up 572 ExtraMenus::iterator mit = m_extramenus.begin();
573 delete mit->second; 573 ExtraMenus::iterator mit_end = m_extramenus.end();
574 } else { 574 for (; mit != mit_end; ++mit) {
575 // let the parent clean it up 575 // we set them to NOT internal so that they will be deleted when the
576 mit->second->setInternalMenu(false); 576 // menu is cleaned up. We can't delete them here because they are
577 // still in the menu
578 // (They need to be internal for most of the time so that if we
579 // rebuild the menu, then they won't be removed.
580 if (! extramenus_in_windowmenu) {
581 // not attached to our windowmenu
582 // so we clean it up
583 delete mit->second;
584 } else {
585 // let the parent clean it up
586 mit->second->setInternalMenu(false);
587 }
577 } 588 }
578 } 589 }
579 590