浏览代码

Bug 1585: Failure when using Ctrl+Tab keyboard shortcut with no session opened

https://winscp.net/tracker/1585
(cherry picked from commit de7d1a13b0463ec30beb8e4add49c67ac09de8d6)

Source commit: 6e2497486149f1da6564f8124f2dc791dc2baea9
Martin Prikryl 8 年之前
父节点
当前提交
fdbbdad133
共有 1 个文件被更改,包括 12 次插入9 次删除
  1. 12 9
      source/windows/TerminalManager.cpp

+ 12 - 9
source/windows/TerminalManager.cpp

@@ -1280,17 +1280,20 @@ TTerminalQueue * __fastcall TTerminalManager::GetActiveQueue()
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 void __fastcall TTerminalManager::CycleTerminals(bool Forward)
 void __fastcall TTerminalManager::CycleTerminals(bool Forward)
 {
 {
-  int Index = ActiveTerminalIndex;
-  Index += Forward ? 1 : -1;
-  if (Index < 0)
+  if (Count > 0)
   {
   {
-    Index = Count-1;
-  }
-  else if (Index >= Count)
-  {
-    Index = 0;
+    int Index = ActiveTerminalIndex;
+    Index += Forward ? 1 : -1;
+    if (Index < 0)
+    {
+      Index = Count-1;
+    }
+    else if (Index >= Count)
+    {
+      Index = 0;
+    }
+    ActiveTerminalIndex = Index;
   }
   }
-  ActiveTerminalIndex = Index;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 bool __fastcall TTerminalManager::CanOpenInPutty()
 bool __fastcall TTerminalManager::CanOpenInPutty()