diff options
author | rathnor <rathnor> | 2004-08-29 12:35:29 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2004-08-29 12:35:29 (GMT) |
commit | ef9565efd8431eed3f561154c58765d5a77be90a (patch) | |
tree | dc0de9202454de040cd88db5e076d1ded565a4e7 /src | |
parent | 92dc8d745214ac4f8c81bbad6d529a19fb4fe46c (diff) | |
download | fluxbox-ef9565efd8431eed3f561154c58765d5a77be90a.zip fluxbox-ef9565efd8431eed3f561154c58765d5a77be90a.tar.bz2 |
fix crash bug when windowmenu doesn't include extramenus
improve checking of existence/success of loading windowmenu file
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Menu.hh | 7 | ||||
-rw-r--r-- | src/MenuCreator.cc | 16 | ||||
-rw-r--r-- | src/MenuCreator.hh | 4 | ||||
-rw-r--r-- | src/Window.cc | 18 |
4 files changed, 28 insertions, 17 deletions
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 57894b8..d5f6b83 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Menu.hh,v 1.38 2004/08/03 21:25:51 fluxgen Exp $ | 25 | // $Id: Menu.hh,v 1.39 2004/08/29 12:35:29 rathnor Exp $ |
26 | 26 | ||
27 | #ifndef FBTK_MENU_HH | 27 | #ifndef FBTK_MENU_HH |
28 | #define FBTK_MENU_HH | 28 | #define FBTK_MENU_HH |
@@ -162,6 +162,9 @@ public: | |||
162 | /// @return true if index is valid | 162 | /// @return true if index is valid |
163 | inline bool validIndex(int index) const { return (index < static_cast<int>(numberOfItems()) && index >= 0); } | 163 | inline bool validIndex(int index) const { return (index < static_cast<int>(numberOfItems()) && index >= 0); } |
164 | 164 | ||
165 | inline Menu *parent() { return m_parent; } | ||
166 | inline const Menu *parent() const { return m_parent; } | ||
167 | |||
165 | protected: | 168 | protected: |
166 | 169 | ||
167 | inline void setTitleVisibility(bool b) { | 170 | inline void setTitleVisibility(bool b) { |
@@ -179,8 +182,6 @@ protected: | |||
179 | unsigned int width= 0, unsigned int height= 0); | 182 | unsigned int width= 0, unsigned int height= 0); |
180 | virtual void redrawTitle(); | 183 | virtual void redrawTitle(); |
181 | virtual void internal_hide(); | 184 | virtual void internal_hide(); |
182 | inline Menu *parent() { return m_parent; } | ||
183 | inline const Menu *parent() const { return m_parent; } | ||
184 | 185 | ||
185 | void update(FbTk::Subject *); | 186 | void update(FbTk::Subject *); |
186 | void renderTransp(int x, int y, | 187 | void renderTransp(int x, int y, |
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 374411d..9c3cb4f 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -20,7 +20,7 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: MenuCreator.cc,v 1.11 2004/08/26 18:26:39 akir Exp $ | 23 | // $Id: MenuCreator.cc,v 1.12 2004/08/29 12:35:29 rathnor Exp $ |
24 | 24 | ||
25 | #include "MenuCreator.hh" | 25 | #include "MenuCreator.hh" |
26 | 26 | ||
@@ -322,36 +322,38 @@ FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_ | |||
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | void MenuCreator::createFromFile(const std::string &filename, | 325 | bool MenuCreator::createFromFile(const std::string &filename, |
326 | FbTk::Menu &inject_into) { | 326 | FbTk::Menu &inject_into) { |
327 | 327 | ||
328 | std::string real_filename = FbTk::StringUtil::expandFilename(filename); | 328 | std::string real_filename = FbTk::StringUtil::expandFilename(filename); |
329 | FbMenuParser parser(real_filename); | 329 | FbMenuParser parser(real_filename); |
330 | if (!parser.isLoaded()) | 330 | if (!parser.isLoaded()) |
331 | return; | 331 | return false; |
332 | 332 | ||
333 | std::string label; | 333 | std::string label; |
334 | if (!getStart(parser, label)) | 334 | if (!getStart(parser, label)) |
335 | return; | 335 | return false; |
336 | 336 | ||
337 | parseMenu(parser, inject_into); | 337 | parseMenu(parser, inject_into); |
338 | return true; | ||
338 | } | 339 | } |
339 | 340 | ||
340 | 341 | ||
341 | void MenuCreator::createFromFile(const std::string &filename, | 342 | bool MenuCreator::createFromFile(const std::string &filename, |
342 | FbTk::Menu &inject_into, | 343 | FbTk::Menu &inject_into, |
343 | FluxboxWindow &win) { | 344 | FluxboxWindow &win) { |
344 | std::string real_filename = FbTk::StringUtil::expandFilename(filename); | 345 | std::string real_filename = FbTk::StringUtil::expandFilename(filename); |
345 | FbMenuParser parser(real_filename); | 346 | FbMenuParser parser(real_filename); |
346 | if (!parser.isLoaded()) | 347 | if (!parser.isLoaded()) |
347 | return; | 348 | return false; |
348 | 349 | ||
349 | std::string label; | 350 | std::string label; |
350 | 351 | ||
351 | if (!getStart(parser, label)) | 352 | if (!getStart(parser, label)) |
352 | return; | 353 | return false; |
353 | 354 | ||
354 | parseWindowMenu(parser, inject_into, win); | 355 | parseWindowMenu(parser, inject_into, win); |
356 | return true; | ||
355 | } | 357 | } |
356 | 358 | ||
357 | 359 | ||
diff --git a/src/MenuCreator.hh b/src/MenuCreator.hh index d9625f3..f916bfd 100644 --- a/src/MenuCreator.hh +++ b/src/MenuCreator.hh | |||
@@ -36,8 +36,8 @@ public: | |||
36 | static FbTk::Menu *createMenu(const std::string &label, int screen_num); | 36 | static FbTk::Menu *createMenu(const std::string &label, int screen_num); |
37 | static FbTk::Menu *createFromFile(const std::string &filename, int screen_num); | 37 | static FbTk::Menu *createFromFile(const std::string &filename, int screen_num); |
38 | static FbTk::Menu *createMenuType(const std::string &label, int screen_num); | 38 | static FbTk::Menu *createMenuType(const std::string &label, int screen_num); |
39 | static void createFromFile(const std::string &filename, FbTk::Menu &inject_into); | 39 | static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into); |
40 | static void createFromFile(const std::string &filename, FbTk::Menu &inject_into, | 40 | static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into, |
41 | FluxboxWindow &win); | 41 | FluxboxWindow &win); |
42 | static bool createWindowMenuItem(const std::string &type, const std::string &label, | 42 | static bool createWindowMenuItem(const std::string &type, const std::string &label, |
43 | FbTk::Menu &inject_into, FluxboxWindow &win); | 43 | FbTk::Menu &inject_into, FluxboxWindow &win); |
diff --git a/src/Window.cc b/src/Window.cc index 2528a8c..c3f6190 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.296 2004/08/13 12:39:02 fluxgen Exp $ | 25 | // $Id: Window.cc,v 1.297 2004/08/29 12:35:29 rathnor Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -350,7 +350,14 @@ FluxboxWindow::~FluxboxWindow() { | |||
350 | // still in the menu | 350 | // still in the menu |
351 | // (They need to be internal for most of the time so that if we | 351 | // (They need to be internal for most of the time so that if we |
352 | // rebuild the menu, then they won't be removed. | 352 | // rebuild the menu, then they won't be removed. |
353 | mit->second->setInternalMenu(false); | 353 | if (mit->second->parent() == 0) { |
354 | // not attached to our windowmenu | ||
355 | // so we clean it up | ||
356 | delete mit->second; | ||
357 | } else { | ||
358 | // let the parent clean it up | ||
359 | mit->second->setInternalMenu(false); | ||
360 | } | ||
354 | } | 361 | } |
355 | 362 | ||
356 | #ifdef DEBUG | 363 | #ifdef DEBUG |
@@ -3562,9 +3569,10 @@ void FluxboxWindow::setupMenu() { | |||
3562 | menu().removeAll(); // clear old items | 3569 | menu().removeAll(); // clear old items |
3563 | menu().disableTitle(); // not titlebar | 3570 | menu().disableTitle(); // not titlebar |
3564 | 3571 | ||
3565 | if (!screen().windowMenuFilename().empty()) { | 3572 | if (screen().windowMenuFilename().empty() || |
3566 | MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this); | 3573 | ! MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this)) |
3567 | } else { | 3574 | |
3575 | { | ||
3568 | MenuCreator::createWindowMenuItem("shade", "", menu(), *this); | 3576 | MenuCreator::createWindowMenuItem("shade", "", menu(), *this); |
3569 | MenuCreator::createWindowMenuItem("stick", "", menu(), *this); | 3577 | MenuCreator::createWindowMenuItem("stick", "", menu(), *this); |
3570 | MenuCreator::createWindowMenuItem("maximize", "", menu(), *this); | 3578 | MenuCreator::createWindowMenuItem("maximize", "", menu(), *this); |