cleaning
fluxgen fluxgen
2 files changed,
25 insertions(+),
33 deletions(-)
M
src/Screen.cc
→
src/Screen.cc
@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.267 2004/02/20 09:06:19 fluxgen Exp $ +// $Id: Screen.cc,v 1.268 2004/02/27 12:32:54 fluxgen Exp $ #include "Screen.hh"@@ -641,6 +641,17 @@
XFlush(disp); } +template <typename A> +void destroyAndClearList(A &a) { + typedef typename A::iterator iterator; + iterator it = a.begin(); + iterator it_end = a.end(); + for (; it != it_end; ++it) + delete (*it); + + a.clear(); +} + BScreen::~BScreen() { if (! managed) return;@@ -656,27 +667,9 @@ imageControl().removeImage(pos_pixmap);
removeWorkspaceNames(); - Workspaces::iterator w_it = m_workspaces_list.begin(); - Workspaces::iterator w_it_end = m_workspaces_list.end(); - for(; w_it != w_it_end; ++w_it) { - delete (*w_it); - } - m_workspaces_list.clear(); - - Icons::iterator i_it = m_icon_list.begin(); - Icons::iterator i_it_end = m_icon_list.end(); - for(; i_it != i_it_end; ++i_it) { - delete (*i_it); - } - m_icon_list.clear(); - - Netizens::iterator n_it = m_netizen_list.begin(); - Netizens::iterator n_it_end = m_netizen_list.end(); - for(; n_it != n_it_end; ++n_it) { - delete (*n_it); - } - - m_netizen_list.clear(); + destroyAndClearList(m_workspaces_list); + destroyAndClearList(m_icon_list); + destroyAndClearList(m_netizen_list); if (hasXinerama() && m_xinerama_headinfo) { delete [] m_xinerama_headinfo;
M
src/fluxbox.cc
→
src/fluxbox.cc
@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.231 2004/02/20 09:29:05 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.232 2004/02/27 12:30:17 fluxgen Exp $ #include "fluxbox.hh"@@ -48,6 +48,7 @@ #include "FbTk/XrmDatabaseHelper.hh"
#include "FbTk/Command.hh" #include "FbTk/RefCount.hh" #include "FbTk/SimpleCommand.hh" +#include "FbTk/CompareEqual.hh" //Use GNU extensions #ifndef _GNU_SOURCE@@ -837,14 +838,11 @@ &attr) && attr.screen != 0) {
screen_num = XScreenNumberOfScreen(attr.screen); // find screen - ScreenList::iterator screen_it = m_screen_list.begin(); - const ScreenList::iterator screen_it_end = m_screen_list.end(); - for (; screen_it != screen_it_end; ++screen_it) { - if ((*screen_it)->screenNumber() == screen_num) { - screen = (*screen_it); - break; - } - } + ScreenList::iterator screen_it = find_if(m_screen_list.begin(), + m_screen_list.end(), + FbTk::CompareEqual<BScreen>(&BScreen::screenNumber, screen_num)); + if (screen_it != m_screen_list.end()) + screen = *screen_it; } // try with parent if we failed to find screen num if (screen == 0)@@ -1435,11 +1433,12 @@ }
} BScreen *Fluxbox::searchScreen(Window window) { - ScreenList::iterator it = m_screen_list.begin(); + + ScreenList::iterator it = m_screen_list.begin(); ScreenList::iterator it_end = m_screen_list.end(); for (; it != it_end; ++it) { if (*it && (*it)->rootWindow() == window) - return (*it); + return *it; } return 0;