diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-02 15:21:24 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-17 00:09:35 (GMT) |
commit | b9de0c5be3022db926e167fbe765dc222c1db828 (patch) | |
tree | 3af2cb3b644e2986d904f486fe73a5e158757009 /src/FbTk/Menu.hh | |
parent | db435c66cce9644abf5599f62229426b1f09a9e3 (diff) | |
download | fluxbox_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/FbTk/Menu.hh')
-rw-r--r-- | src/FbTk/Menu.hh | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 4096295..5807592 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -65,14 +65,13 @@ public: | |||
65 | /// add empty menu item | 65 | /// add empty menu item |
66 | int insert(const FbString &label, int pos=-1); | 66 | int insert(const FbString &label, int pos=-1); |
67 | /// add submenu | 67 | /// add submenu |
68 | int insert(const FbString &label, Menu *submenu, int pos= -1); | 68 | int insert(const FbString &label, const RefCount<Menu> &submenu, int pos= -1); |
69 | /// add menu item | 69 | /// add menu item |
70 | int insert(MenuItem *item, int pos=-1); | 70 | int insert(MenuItem *item, int pos=-1); |
71 | /// remove an item | 71 | /// remove an item |
72 | int remove(unsigned int item); | 72 | int remove(unsigned int item); |
73 | /// remove all items | 73 | /// remove all items |
74 | void removeAll(); | 74 | void removeAll(); |
75 | void setInternalMenu(bool val = true) { m_internal_menu = val; } | ||
76 | void setAlignment(Alignment a) { m_alignment = a; } | 75 | void setAlignment(Alignment a) { m_alignment = a; } |
77 | 76 | ||
78 | /// raise this window | 77 | /// raise this window |
@@ -213,7 +212,6 @@ private: | |||
213 | bool m_closing; ///< if we're right clicking on the menu title | 212 | bool m_closing; ///< if we're right clicking on the menu title |
214 | bool m_visible; ///< menu visibility | 213 | bool m_visible; ///< menu visibility |
215 | bool m_torn; ///< torn from parent | 214 | bool m_torn; ///< torn from parent |
216 | bool m_internal_menu; ///< whether we should destroy this menu or if it's managed somewhere else | ||
217 | bool m_title_vis; ///< title visibility | 215 | bool m_title_vis; ///< title visibility |
218 | 216 | ||
219 | int m_which_sub; | 217 | int m_which_sub; |