aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.hh
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/Screen.hh
parent0584414d3845239202d5ea02da2ce6fb5b1b0cbb (diff)
downloadfluxbox_pavel-f2709b26d8af7292f750fc05525ac90ad0d99c41.zip
fluxbox_pavel-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/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 138cd1c..6492104 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"
@@ -55,7 +56,6 @@
55#include <map> 56#include <map>
56 57
57class ClientPattern; 58class ClientPattern;
58class FbMenu;
59class Focusable; 59class Focusable;
60class FluxboxWindow; 60class FluxboxWindow;
61class WinClient; 61class WinClient;
@@ -86,7 +86,7 @@ public:
86 86
87 typedef std::vector<Workspace *> Workspaces; 87 typedef std::vector<Workspace *> Workspaces;
88 typedef std::vector<std::string> WorkspaceNames; 88 typedef std::vector<std::string> WorkspaceNames;
89 typedef std::list<std::pair<FbTk::FbString, FbTk::Menu *> > ExtraMenus; 89 typedef std::list<std::pair<FbTk::FbString, FbTk::RefCount<FbTk::Menu> > > ExtraMenus;
90 90
91 BScreen(FbTk::ResourceManager_base &rm, 91 BScreen(FbTk::ResourceManager_base &rm,
92 const std::string &screenname, 92 const std::string &screenname,
@@ -113,8 +113,8 @@ public:
113 // menus 113 // menus
114 const FbMenu &rootMenu() const { return *m_rootmenu.get(); } 114 const FbMenu &rootMenu() const { return *m_rootmenu.get(); }
115 FbMenu &rootMenu() { return *m_rootmenu.get(); } 115 FbMenu &rootMenu() { return *m_rootmenu.get(); }
116 const FbMenu &configMenu() const { return *m_configmenu.get(); } 116 FbTk::RefCount<const FbMenu> configMenu() const { return m_configmenu; }
117 FbMenu &configMenu() { return *m_configmenu.get(); } 117 const FbTk::RefCount<FbMenu> &configMenu() { return m_configmenu; }
118 const FbMenu &windowMenu() const { return *m_windowmenu.get(); } 118 const FbMenu &windowMenu() const { return *m_windowmenu.get(); }
119 FbMenu &windowMenu() { return *m_windowmenu.get(); } 119 FbMenu &windowMenu() { return *m_windowmenu.get(); }
120 ExtraMenus &extraWindowMenus() { return m_extramenus; } 120 ExtraMenus &extraWindowMenus() { return m_extramenus; }
@@ -150,9 +150,9 @@ public:
150 Workspace *currentWorkspace() { return m_current_workspace; } 150 Workspace *currentWorkspace() { return m_current_workspace; }
151 const Workspace *currentWorkspace() const { return m_current_workspace; } 151 const Workspace *currentWorkspace() const { return m_current_workspace; }
152 /// @return the workspace menu 152 /// @return the workspace menu
153 const FbMenu &workspaceMenu() const { return *m_workspacemenu.get(); } 153 FbTk::RefCount<const FbMenu> workspaceMenu() const { return m_workspacemenu; }
154 /// @return the workspace menu 154 /// @return the workspace menu
155 FbMenu &workspaceMenu() { return *m_workspacemenu.get(); } 155 const FbTk::RefCount<FbMenu> &workspaceMenu() { return m_workspacemenu; }
156 /// @return focus control handler 156 /// @return focus control handler
157 const FocusControl &focusControl() const { return *m_focus_control; } 157 const FocusControl &focusControl() const { return *m_focus_control; }
158 /// @return focus control handler 158 /// @return focus control handler
@@ -246,10 +246,8 @@ public:
246 246
247 /** 247 /**
248 * For extras to add menus. 248 * For extras to add menus.
249 * These menus will be marked internal,
250 * and deleted when the window dies (as opposed to Screen
251 */ 249 */
252 void addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu); 250 void addExtraWindowMenu(const FbTk::FbString &label, const FbTk::RefCount<FbTk::Menu> &menu);
253 251
254 int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } 252 int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; }
255 253
@@ -443,8 +441,8 @@ public:
443 // for extras to add menus. These menus must be marked 441 // for extras to add menus. These menus must be marked
444 // internal for their safety, and __the extension__ must 442 // internal for their safety, and __the extension__ must
445 // delete and remove the menu itself (opposite to Window) 443 // delete and remove the menu itself (opposite to Window)
446 void addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu); 444 void addConfigMenu(const FbTk::FbString &label, const FbTk::RefCount<FbTk::Menu> &menu);
447 void removeConfigMenu(FbTk::Menu &menu); 445 void removeConfigMenu(const FbTk::RefCount<FbTk::Menu> &menu);
448 446
449 447
450 /// Adds a resource to managed resource list 448 /// Adds a resource to managed resource list
@@ -478,11 +476,11 @@ private:
478 bool root_colormap_installed, managed; 476 bool root_colormap_installed, managed;
479 477
480 std::auto_ptr<FbTk::ImageControl> m_image_control; 478 std::auto_ptr<FbTk::ImageControl> m_image_control;
481 std::auto_ptr<FbMenu> m_configmenu, m_rootmenu, m_workspacemenu, m_windowmenu; 479 FbTk::RefCount<FbMenu> m_configmenu, m_rootmenu, m_workspacemenu, m_windowmenu;
482 480
483 ExtraMenus m_extramenus; 481 ExtraMenus m_extramenus;
484 482
485 typedef std::list<std::pair<FbTk::FbString, FbTk::Menu *> > Configmenus; 483 typedef std::list<std::pair<FbTk::FbString, FbTk::RefCount<FbTk::Menu> > > Configmenus;
486 484
487 485
488 Configmenus m_configmenu_list; 486 Configmenus m_configmenu_list;