aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.hh
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-02 15:21:24 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2012-04-07 02:11:29 (GMT)
commit34649e86c5cbe9c9f231c049a0844afdda5a7db9 (patch)
tree6e9696e36565e993185c9d265ca6542b77788fd9 /src/Screen.hh
parent0b0ee8dc504016ffad85ec1dd35875d273cf0179 (diff)
downloadfluxbox_paul-34649e86c5cbe9c9f231c049a0844afdda5a7db9.zip
fluxbox_paul-34649e86c5cbe9c9f231c049a0844afdda5a7db9.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/Screen.hh')
-rw-r--r--src/Screen.hh24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Screen.hh b/src/Screen.hh
index 8c89ab2..3e062ac 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -25,6 +25,7 @@
25#ifndef SCREEN_HH 25#ifndef SCREEN_HH
26#define SCREEN_HH 26#define SCREEN_HH
27 27
28#include "FbMenu.hh"
28#include "FbWinFrame.hh" 29#include "FbWinFrame.hh"
29#include "FbRootWindow.hh" 30#include "FbRootWindow.hh"
30#include "RootTheme.hh" 31#include "RootTheme.hh"
@@ -56,7 +57,6 @@
56#include <map> 57#include <map>
57 58
58class ClientPattern; 59class ClientPattern;
59class FbMenu;
60class Focusable; 60class Focusable;
61class FluxboxWindow; 61class FluxboxWindow;
62class WinClient; 62class WinClient;
@@ -87,7 +87,7 @@ public:
87 87
88 typedef std::vector<Workspace *> Workspaces; 88 typedef std::vector<Workspace *> Workspaces;
89 typedef std::vector<std::string> WorkspaceNames; 89 typedef std::vector<std::string> WorkspaceNames;
90 typedef std::list<std::pair<FbTk::FbString, FbTk::Menu *> > ExtraMenus; 90 typedef std::list<std::pair<FbTk::FbString, FbTk::RefCount<FbTk::Menu> > > ExtraMenus;
91 91
92 BScreen(FbTk::ResourceManager_base &rm, 92 BScreen(FbTk::ResourceManager_base &rm,
93 const std::string &screenname, 93 const std::string &screenname,
@@ -114,8 +114,8 @@ public:
114 // menus 114 // menus
115 const FbMenu &rootMenu() const { return *m_rootmenu.get(); } 115 const FbMenu &rootMenu() const { return *m_rootmenu.get(); }
116 FbMenu &rootMenu() { return *m_rootmenu.get(); } 116 FbMenu &rootMenu() { return *m_rootmenu.get(); }
117 const FbMenu &configMenu() const { return *m_configmenu.get(); } 117 FbTk::RefCount<const FbMenu> configMenu() const { return m_configmenu; }
118 FbMenu &configMenu() { return *m_configmenu.get(); } 118 const FbTk::RefCount<FbMenu> &configMenu() { return m_configmenu; }
119 const FbMenu &windowMenu() const { return *m_windowmenu.get(); } 119 const FbMenu &windowMenu() const { return *m_windowmenu.get(); }
120 FbMenu &windowMenu() { return *m_windowmenu.get(); } 120 FbMenu &windowMenu() { return *m_windowmenu.get(); }
121 ExtraMenus &extraWindowMenus() { return m_extramenus; } 121 ExtraMenus &extraWindowMenus() { return m_extramenus; }
@@ -151,9 +151,9 @@ public:
151 Workspace *currentWorkspace() { return m_current_workspace; } 151 Workspace *currentWorkspace() { return m_current_workspace; }
152 const Workspace *currentWorkspace() const { return m_current_workspace; } 152 const Workspace *currentWorkspace() const { return m_current_workspace; }
153 /// @return the workspace menu 153 /// @return the workspace menu
154 const FbMenu &workspaceMenu() const { return *m_workspacemenu.get(); } 154 FbTk::RefCount<const FbMenu> workspaceMenu() const { return m_workspacemenu; }
155 /// @return the workspace menu 155 /// @return the workspace menu
156 FbMenu &workspaceMenu() { return *m_workspacemenu.get(); } 156 const FbTk::RefCount<FbMenu> &workspaceMenu() { return m_workspacemenu; }
157 /// @return focus control handler 157 /// @return focus control handler
158 const FocusControl &focusControl() const { return *m_focus_control; } 158 const FocusControl &focusControl() const { return *m_focus_control; }
159 /// @return focus control handler 159 /// @return focus control handler
@@ -247,10 +247,8 @@ public:
247 247
248 /** 248 /**
249 * For extras to add menus. 249 * For extras to add menus.
250 * These menus will be marked internal,
251 * and deleted when the window dies (as opposed to Screen
252 */ 250 */
253 void addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu); 251 void addExtraWindowMenu(const FbTk::FbString &label, const FbTk::RefCount<FbTk::Menu> &menu);
254 252
255 int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } 253 int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; }
256 254
@@ -444,8 +442,8 @@ public:
444 // for extras to add menus. These menus must be marked 442 // for extras to add menus. These menus must be marked
445 // internal for their safety, and __the extension__ must 443 // internal for their safety, and __the extension__ must
446 // delete and remove the menu itself (opposite to Window) 444 // delete and remove the menu itself (opposite to Window)
447 void addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu); 445 void addConfigMenu(const FbTk::FbString &label, const FbTk::RefCount<FbTk::Menu> &menu);
448 void removeConfigMenu(FbTk::Menu &menu); 446 void removeConfigMenu(const FbTk::RefCount<FbTk::Menu> &menu);
449 447
450 448
451 /// Adds a resource to managed resource list 449 /// Adds a resource to managed resource list
@@ -495,11 +493,11 @@ private:
495 bool root_colormap_installed, managed; 493 bool root_colormap_installed, managed;
496 494
497 std::auto_ptr<FbTk::ImageControl> m_image_control; 495 std::auto_ptr<FbTk::ImageControl> m_image_control;
498 std::auto_ptr<FbMenu> m_configmenu, m_rootmenu, m_workspacemenu, m_windowmenu; 496 FbTk::RefCount<FbMenu> m_configmenu, m_rootmenu, m_workspacemenu, m_windowmenu;
499 497
500 ExtraMenus m_extramenus; 498 ExtraMenus m_extramenus;
501 499
502 typedef std::list<std::pair<FbTk::FbString, FbTk::Menu *> > Configmenus; 500 typedef std::list<std::pair<FbTk::FbString, FbTk::RefCount<FbTk::Menu> > > Configmenus;
503 501
504 502
505 Configmenus m_configmenu_list; 503 Configmenus m_configmenu_list;