From 6a21f547072ce992c9b3255eb47dcfb5e748e531 Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 8 Sep 2007 18:41:03 +0000 Subject: fix crash from changing toolbar visibility, some cleanup, and porting change from trunk --- src/FbTk/Menu.cc | 2 +- src/FbTk/MenuItem.cc | 7 +++++-- src/FbTk/Subject.cc | 2 +- src/MenuCreator.cc | 2 +- src/Remember.cc | 2 +- src/Toolbar.cc | 2 +- src/Window.cc | 6 +++++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index f10f1b7..23efcfe 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -502,7 +502,7 @@ void Menu::updateMenu(int active_index) { void Menu::show() { - if (isVisible() || !menuitems.size()) + if (isVisible() || menuitems.empty()) return; m_visible = true; diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index b598c47..2576d2b 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -34,8 +34,11 @@ namespace FbTk { void MenuItem::click(int button, int time) { - if (m_command.get() != 0) - m_command->execute(); + if (m_command.get() != 0) { + // we need a local variable, since the command may destroy this object + RefCount tmp(m_command); + tmp->execute(); + } } void MenuItem::drawLine(FbDrawable &draw, const MenuTheme &theme, size_t size, diff --git a/src/FbTk/Subject.cc b/src/FbTk/Subject.cc index 2b30fd8..08a211c 100644 --- a/src/FbTk/Subject.cc +++ b/src/FbTk/Subject.cc @@ -64,7 +64,7 @@ void Subject::notify() { m_notify_mode = false; // remove dead observers - if (m_dead_observers.size()) { + if (!m_dead_observers.empty()) { std::for_each(m_dead_observers.begin(), m_dead_observers.end(), std::bind1st(std::mem_fun(&Subject::detach), this)); diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 3c2843f..a99d785 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -323,7 +323,7 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve if (submenu == 0) return; - if (str_cmd.size()) + if (!str_cmd.empty()) submenu->setLabel(str_cmd); else submenu->setLabel(str_label); diff --git a/src/Remember.cc b/src/Remember.cc index 017188e..fbb4a2e 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -387,7 +387,7 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) { bool had_error = false; - if (!str_key.size()) + if (str_key.empty()) continue; //read next line if (strcasecmp(str_key.c_str(), "Workspace") == 0) { unsigned int w; diff --git a/src/Toolbar.cc b/src/Toolbar.cc index c5eff60..54ee239 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -416,7 +416,7 @@ void Toolbar::reconfigure() { m_tools = tools; // copy values - if (m_tools.size()) { + if (!m_tools.empty()) { // make lower case transform(m_tools.begin(), m_tools.end(), m_tools.begin(), diff --git a/src/Window.cc b/src/Window.cc index b9ef2ff..a5cf6fd 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2605,10 +2605,14 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { - if ((re.button == 1) && (re.state & Mod1Mask) && !screen().clickRaises()) + if ((re.button == 1) && (re.state & Fluxbox::instance()->getModKey()) + && !screen().clickRaises()) { + if (!isMoving()) raise(); + } + if (isMoving()) stopMoving(); else if (isResizing()) -- cgit v0.11.2