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>2011-11-01 09:57:20 (GMT)
commitf2709b26d8af7292f750fc05525ac90ad0d99c41 (patch)
tree794903544922abe2b90af6250de24124cd94d546 /src/WorkspaceMenu.cc
parent0584414d3845239202d5ea02da2ce6fb5b1b0cbb (diff)
downloadfluxbox_paul-f2709b26d8af7292f750fc05525ac90ad0d99c41.zip
fluxbox_paul-f2709b26d8af7292f750fc05525ac90ad0d99c41.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);