aboutsummaryrefslogtreecommitdiff
path: root/src/WorkspaceMenu.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-02 15:21:24 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-17 00:09:35 (GMT)
commitb9de0c5be3022db926e167fbe765dc222c1db828 (patch)
tree3af2cb3b644e2986d904f486fe73a5e158757009 /src/WorkspaceMenu.cc
parentdb435c66cce9644abf5599f62229426b1f09a9e3 (diff)
downloadfluxbox_pavel-b9de0c5be3022db926e167fbe765dc222c1db828.zip
fluxbox_pavel-b9de0c5be3022db926e167fbe765dc222c1db828.tar.bz2
Store menus if smart pointers (RefCount)
This was originally intended to be a bugfix for an memory error reported by valgrind (accessing freed memory). While debugging it, I found the menu ownership semantics confusing (setInternalMenu() et al.), so I decided to get rid of it and store it in smart pointers everywhere. Looking back, I'm not sure if this was worth all the trouble, but the good news is that the valgrind error disappeared. :)
Diffstat (limited to 'src/WorkspaceMenu.cc')
-rw-r--r--src/WorkspaceMenu.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
index d73947b..0b563aa 100644
--- a/src/WorkspaceMenu.cc
+++ b/src/WorkspaceMenu.cc
@@ -56,8 +56,7 @@ const unsigned int NR_STATIC_ITEMS = 6;
56void add_workspaces(WorkspaceMenu& menu, BScreen& screen) { 56void add_workspaces(WorkspaceMenu& menu, BScreen& screen) {
57 for (size_t i = 0; i < screen.numberOfWorkspaces(); ++i) { 57 for (size_t i = 0; i < screen.numberOfWorkspaces(); ++i) {
58 Workspace* w = screen.getWorkspace(i); 58 Workspace* w = screen.getWorkspace(i);
59 w->menu().setInternalMenu(); 59 FbTk::MultiButtonMenuItem* submenu = new FbTk::MultiButtonMenuItem(5, FbTk::BiDiString(w->name()), w->menu());
60 FbTk::MultiButtonMenuItem* submenu = new FbTk::MultiButtonMenuItem(5, FbTk::BiDiString(w->name()), &w->menu());
61 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(w->workspaceID())); 60 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(w->workspaceID()));
62 submenu->setCommand(3, jump_cmd); 61 submenu->setCommand(3, jump_cmd);
63 menu.insert(submenu, i + IDX_AFTER_ICONS); 62 menu.insert(submenu, i + IDX_AFTER_ICONS);
@@ -112,7 +111,7 @@ void WorkspaceMenu::init(BScreen &screen) {
112 111
113 setLabel(_FB_XTEXT(Workspace, MenuTitle, "Workspaces", "Title of main workspace menu")); 112 setLabel(_FB_XTEXT(Workspace, MenuTitle, "Workspaces", "Title of main workspace menu"));
114 insert(_FB_XTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), 113 insert(_FB_XTEXT(Menu, Icons, "Icons", "Iconic windows menu title"),
115 MenuCreator::createMenuType("iconmenu", screen.screenNumber())); 114 FbTk::RefCount<FbTk::Menu>(MenuCreator::createMenuType("iconmenu", screen.screenNumber())) );
116 insert(new FbTk::MenuSeparator()); 115 insert(new FbTk::MenuSeparator());
117 116
118 ::add_workspaces(*this, screen); 117 ::add_workspaces(*this, screen);