aboutsummaryrefslogtreecommitdiff
path: root/src/ToolFactory.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-02 15:21:24 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-07-02 15:21:24 (GMT)
commit442e69c89b721329883113389f889675138e7da7 (patch)
tree211111eb98eb3da6155baea0a24c5cd9d8c6137d /src/ToolFactory.cc
parentbd94eaa6cadfd0a7d83f3068a84b27f987bdee4b (diff)
downloadfluxbox_pavel-442e69c89b721329883113389f889675138e7da7.zip
fluxbox_pavel-442e69c89b721329883113389f889675138e7da7.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/ToolFactory.cc')
-rw-r--r--src/ToolFactory.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc
index d94105d..007cabf 100644
--- a/src/ToolFactory.cc
+++ b/src/ToolFactory.cc
@@ -49,7 +49,7 @@ public:
49 49
50 m_tbar.screen() 50 m_tbar.screen()
51 .placementStrategy() 51 .placementStrategy()
52 .placeAndShowMenu(m_tbar.menu(), e.xbutton.x_root, e.xbutton.y_root, false); 52 .placeAndShowMenu(*m_tbar.menu(), e.xbutton.x_root, e.xbutton.y_root, false);
53 } 53 }
54private: 54private:
55 Toolbar &m_tbar; 55 Toolbar &m_tbar;
@@ -85,11 +85,11 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &
85 witem->button().setOnClick(showmenu); 85 witem->button().setOnClick(showmenu);
86 item = witem; 86 item = witem;
87 } else if (name == "iconbar") { 87 } else if (name == "iconbar") {
88 item = new IconbarTool(parent, m_iconbar_theme, m_focused_iconbar_theme, m_unfocused_iconbar_theme, screen(), tbar.menu()); 88 item = new IconbarTool(parent, m_iconbar_theme, m_focused_iconbar_theme, m_unfocused_iconbar_theme, screen(), *tbar.menu());
89 } else if (name == "systemtray") { 89 } else if (name == "systemtray") {
90 item = new SystemTray(parent, dynamic_cast<ButtonTheme &>(*m_systray_theme), screen()); 90 item = new SystemTray(parent, dynamic_cast<ButtonTheme &>(*m_systray_theme), screen());
91 } else if (name == "clock") { 91 } else if (name == "clock") {
92 item = new ClockTool(parent, m_clock_theme, screen(), tbar.menu()); 92 item = new ClockTool(parent, m_clock_theme, screen(), *tbar.menu());
93 } else { 93 } else {
94 FbTk::RefCount<FbTk::Command<void> > cmd(FbTk::CommandParser<void>::instance().parse(name)); 94 FbTk::RefCount<FbTk::Command<void> > cmd(FbTk::CommandParser<void>::instance().parse(name));
95 if (cmd == 0) // we need a command 95 if (cmd == 0) // we need a command