fix crash bug when windowmenu doesn't include extramenus

improve checking of existence/success of loading windowmenu file
This commit is contained in:
rathnor 2004-08-29 12:35:29 +00:00
parent 92dc8d7452
commit ef9565efd8
5 changed files with 34 additions and 17 deletions

View file

@ -1,6 +1,12 @@
(Format: Year/Month/Day)
Changes for 0.9.10:
*04/08/29:
* Fix crash when extramenus not attached to windowmenu (Simon)
- and add checking that windowmenu file exists and sorta parses
Window.cc FbTk/Menu.hh MenuCreator.hh/cc
* Tweak toolbar size/position (esp when 100% width) (Simon)
- and fix menu size bug when initialising with no style
Toolbar.cc FbTk/MenuTheme.cc
* Add back Workspace<n> actions with deprecated message (Simon)
- need transition time, remove when 1.0 has been widely used for a while
FbCommandFactory.cc

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Menu.hh,v 1.38 2004/08/03 21:25:51 fluxgen Exp $
// $Id: Menu.hh,v 1.39 2004/08/29 12:35:29 rathnor Exp $
#ifndef FBTK_MENU_HH
#define FBTK_MENU_HH
@ -162,6 +162,9 @@ public:
/// @return true if index is valid
inline bool validIndex(int index) const { return (index < static_cast<int>(numberOfItems()) && index >= 0); }
inline Menu *parent() { return m_parent; }
inline const Menu *parent() const { return m_parent; }
protected:
inline void setTitleVisibility(bool b) {
@ -179,8 +182,6 @@ protected:
unsigned int width= 0, unsigned int height= 0);
virtual void redrawTitle();
virtual void internal_hide();
inline Menu *parent() { return m_parent; }
inline const Menu *parent() const { return m_parent; }
void update(FbTk::Subject *);
void renderTransp(int x, int y,

View file

@ -20,7 +20,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: MenuCreator.cc,v 1.11 2004/08/26 18:26:39 akir Exp $
// $Id: MenuCreator.cc,v 1.12 2004/08/29 12:35:29 rathnor Exp $
#include "MenuCreator.hh"
@ -322,36 +322,38 @@ FbTk::Menu *MenuCreator::createFromFile(const std::string &filename, int screen_
}
void MenuCreator::createFromFile(const std::string &filename,
bool MenuCreator::createFromFile(const std::string &filename,
FbTk::Menu &inject_into) {
std::string real_filename = FbTk::StringUtil::expandFilename(filename);
FbMenuParser parser(real_filename);
if (!parser.isLoaded())
return;
return false;
std::string label;
if (!getStart(parser, label))
return;
return false;
parseMenu(parser, inject_into);
return true;
}
void MenuCreator::createFromFile(const std::string &filename,
bool MenuCreator::createFromFile(const std::string &filename,
FbTk::Menu &inject_into,
FluxboxWindow &win) {
std::string real_filename = FbTk::StringUtil::expandFilename(filename);
FbMenuParser parser(real_filename);
if (!parser.isLoaded())
return;
return false;
std::string label;
if (!getStart(parser, label))
return;
return false;
parseWindowMenu(parser, inject_into, win);
return true;
}

View file

@ -36,8 +36,8 @@ public:
static FbTk::Menu *createMenu(const std::string &label, int screen_num);
static FbTk::Menu *createFromFile(const std::string &filename, int screen_num);
static FbTk::Menu *createMenuType(const std::string &label, int screen_num);
static void createFromFile(const std::string &filename, FbTk::Menu &inject_into);
static void createFromFile(const std::string &filename, FbTk::Menu &inject_into,
static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into);
static bool createFromFile(const std::string &filename, FbTk::Menu &inject_into,
FluxboxWindow &win);
static bool createWindowMenuItem(const std::string &type, const std::string &label,
FbTk::Menu &inject_into, FluxboxWindow &win);

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Window.cc,v 1.296 2004/08/13 12:39:02 fluxgen Exp $
// $Id: Window.cc,v 1.297 2004/08/29 12:35:29 rathnor Exp $
#include "Window.hh"
@ -350,7 +350,14 @@ FluxboxWindow::~FluxboxWindow() {
// still in the menu
// (They need to be internal for most of the time so that if we
// rebuild the menu, then they won't be removed.
mit->second->setInternalMenu(false);
if (mit->second->parent() == 0) {
// not attached to our windowmenu
// so we clean it up
delete mit->second;
} else {
// let the parent clean it up
mit->second->setInternalMenu(false);
}
}
#ifdef DEBUG
@ -3562,9 +3569,10 @@ void FluxboxWindow::setupMenu() {
menu().removeAll(); // clear old items
menu().disableTitle(); // not titlebar
if (!screen().windowMenuFilename().empty()) {
MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this);
} else {
if (screen().windowMenuFilename().empty() ||
! MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this))
{
MenuCreator::createWindowMenuItem("shade", "", menu(), *this);
MenuCreator::createWindowMenuItem("stick", "", menu(), *this);
MenuCreator::createWindowMenuItem("maximize", "", menu(), *this);