From 0e778b94d955a8a41cfa298cc14748914a31ec3c Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Fri, 4 May 2007 17:14:04 +0000
Subject: fixed infinite loop caused by deiconify command

---
 ChangeLog         | 2 ++
 src/FbCommands.cc | 7 +++++--
 src/Window.cc     | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cad8eaf..eb10656 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
  (Format: Year/Month/Day)
 Changes for 1.1:
+   * Fixed infinite loop caused by deiconify command (Mark)
+     FbCommands.cc
 *07/04/24:
    * Fixed a bug in parsing cli (Mathias, thanks to Steven Kah Hien Wong <steven
      at zensaki dot com> for pointing out the issue)
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index dae4d6a..91474b7 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -424,8 +424,11 @@ void DeiconifyCmd::execute() {
     if (screen == 0)
         return;
 
-    BScreen::Icons::reverse_iterator it= screen->iconList().rbegin();
-    BScreen::Icons::reverse_iterator itend= screen->iconList().rend();
+    // we need to make a copy of the list of icons, or else our iterator can
+    // become invalid
+    BScreen::Icons icon_list = screen->iconList();
+    BScreen::Icons::iterator it = icon_list.begin();
+    BScreen::Icons::iterator itend= icon_list.end();
     unsigned int workspace_num= screen->currentWorkspaceID();
     unsigned int old_workspace_num;
 
diff --git a/src/Window.cc b/src/Window.cc
index e4ade8e..cbbf7a4 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -466,7 +466,7 @@ void FluxboxWindow::init() {
 
     restoreAttributes();
 
-    if (m_workspace_number < 0 || m_workspace_number >= screen().numberOfWorkspaces())
+    if (m_workspace_number >= screen().numberOfWorkspaces())
         m_workspace_number = screen().currentWorkspaceID();
 
     bool place_window = (m_old_pos_x == static_cast<signed>(m_screen.width()));
-- 
cgit v0.11.2