diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-02 15:21:24 (GMT) |
---|---|---|
committer | Paul Tagliamonte <paultag@fluxbox.org> | 2012-04-07 02:11:29 (GMT) |
commit | 34649e86c5cbe9c9f231c049a0844afdda5a7db9 (patch) | |
tree | 6e9696e36565e993185c9d265ca6542b77788fd9 /src/FbTk/Menu.hh | |
parent | 0b0ee8dc504016ffad85ec1dd35875d273cf0179 (diff) | |
download | fluxbox_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/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; |