Pārlūkot izejas kodu

Bug fix: Failure when attempting to switch to an unconnected sessions using keyboard shortcuts while another session is being connected

(cherry picked from commit fcca527ee23619e68d800d8a4e89f64205de48ef)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp
#	source/windows/TerminalManager.cpp

Source commit: a338608d121b23fb7c1bff42b9e6977323cf31c8
Martin Prikryl 3 gadi atpakaļ
vecāks
revīzija
51b0c9a8f1
2 mainītis faili ar 114 papildinājumiem un 97 dzēšanām
  1. 47 44
      source/forms/CustomScpExplorer.cpp
  2. 67 53
      source/windows/TerminalManager.cpp

+ 47 - 44
source/forms/CustomScpExplorer.cpp

@@ -4522,61 +4522,64 @@ void __fastcall TCustomScpExplorerForm::CheckCustomCommandShortCut(
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::KeyDown(Word & Key, Classes::TShiftState Shift)
 {
-  if (QueueView3->Focused() && (QueueView3->OnKeyDown != NULL))
+  if (!NonVisualDataModule->Busy)
   {
-    QueueView3->OnKeyDown(QueueView3, Key, Shift);
-  }
+    if (QueueView3->Focused() && (QueueView3->OnKeyDown != NULL))
+    {
+      QueueView3->OnKeyDown(QueueView3, Key, Shift);
+    }
 
-  if ((Key != 0) && !DirView(osCurrent)->IsEditing())
-  {
-    TShortCut KeyShortCut = ShortCut(Key, Shift);
-    for (int Index = 0; Index < NonVisualDataModule->ExplorerActions->ActionCount; Index++)
+    if ((Key != 0) && !DirView(osCurrent)->IsEditing())
     {
-      TAction * Action = (TAction *)NonVisualDataModule->ExplorerActions->Actions[Index];
-      if (((Action->ShortCut == KeyShortCut) ||
-           (Action->SecondaryShortCuts->IndexOfShortCut(KeyShortCut) >= 0)) &&
-          AllowedAction(Action, aaShortCut))
+      TShortCut KeyShortCut = ShortCut(Key, Shift);
+      for (int Index = 0; Index < NonVisualDataModule->ExplorerActions->ActionCount; Index++)
       {
-        // Has to be called before the action as the dialog char is already in queue.
-        // So when the action consumes message queue, we already need to have the
-        // FIgnoreNextDialogChar set
-        KeyProcessed(Key, Shift);
-        // Reset reference to previous component (when menu/toolbar was clicked).
-        // Needed to detect that action was invoked by keyboard shortcut
-        // in TNonVisualDataModule::ExplorerActionsExecute
-        Action->ActionComponent = NULL;
-        Action->Execute();
-        return;
+        TAction * Action = (TAction *)NonVisualDataModule->ExplorerActions->Actions[Index];
+        if (((Action->ShortCut == KeyShortCut) ||
+             (Action->SecondaryShortCuts->IndexOfShortCut(KeyShortCut) >= 0)) &&
+            AllowedAction(Action, aaShortCut))
+        {
+          // Has to be called before the action as the dialog char is already in queue.
+          // So when the action consumes message queue, we already need to have the
+          // FIgnoreNextDialogChar set
+          KeyProcessed(Key, Shift);
+          // Reset reference to previous component (when menu/toolbar was clicked).
+          // Needed to detect that action was invoked by keyboard shortcut
+          // in TNonVisualDataModule::ExplorerActionsExecute
+          Action->ActionComponent = NULL;
+          Action->Execute();
+          return;
+        }
       }
-    }
-    for (int i = 0; i < TTerminalManager::Instance()->Count; i++)
-    {
-      if (NonVisualDataModule->OpenSessionShortCut(i) == KeyShortCut)
+      for (int i = 0; i < TTerminalManager::Instance()->Count; i++)
+      {
+        if (NonVisualDataModule->OpenSessionShortCut(i) == KeyShortCut)
+        {
+          KeyProcessed(Key, Shift);
+          TTerminalManager::Instance()->ActiveTerminalIndex = i;
+          return;
+        }
+      }
+      if (Key == VK_TAB && Shift.Contains(ssCtrl))
       {
         KeyProcessed(Key, Shift);
-        TTerminalManager::Instance()->ActiveTerminalIndex = i;
-        return;
+        TTerminalManager::Instance()->CycleTerminals(!Shift.Contains(ssShift));
       }
-    }
-    if (Key == VK_TAB && Shift.Contains(ssCtrl))
-    {
-      KeyProcessed(Key, Shift);
-      TTerminalManager::Instance()->CycleTerminals(!Shift.Contains(ssShift));
-    }
 
-    TShortCut CustomShortCut = NormalizeCustomShortCut(KeyShortCut);
-    if (IsCustomShortCut(CustomShortCut))
-    {
-      CheckCustomCommandShortCut(WinConfiguration->CustomCommandList, Key, Shift, CustomShortCut);
-      CheckCustomCommandShortCut(WinConfiguration->ExtensionList, Key, Shift, CustomShortCut);
-
-      if (WinConfiguration->SharedBookmarks != NULL)
+      TShortCut CustomShortCut = NormalizeCustomShortCut(KeyShortCut);
+      if (IsCustomShortCut(CustomShortCut))
       {
-        TBookmark * Bookmark = WinConfiguration->SharedBookmarks->FindByShortCut(CustomShortCut);
-        if ((Bookmark != NULL) &&
-            OpenBookmark(FCurrentSide, Bookmark))
+        CheckCustomCommandShortCut(WinConfiguration->CustomCommandList, Key, Shift, CustomShortCut);
+        CheckCustomCommandShortCut(WinConfiguration->ExtensionList, Key, Shift, CustomShortCut);
+
+        if (WinConfiguration->SharedBookmarks != NULL)
         {
-          KeyProcessed(Key, Shift);
+          TBookmark * Bookmark = WinConfiguration->SharedBookmarks->FindByShortCut(CustomShortCut);
+          if ((Bookmark != NULL) &&
+              OpenBookmark(FCurrentSide, Bookmark))
+          {
+            KeyProcessed(Key, Shift);
+          }
         }
       }
     }

+ 67 - 53
source/windows/TerminalManager.cpp

@@ -679,81 +679,95 @@ void __fastcall TTerminalManager::DoSetActiveTerminal(TManagedTerminal * value,
 {
   if (ActiveTerminal != value)
   {
-    // here used to be call to TCustomScpExporer::UpdateSessionData (now UpdateTerminal)
-    // but it seems to be duplicate to call from TCustomScpExporer::TerminalChanging
-
-    TManagedTerminal * PActiveTerminal = ActiveTerminal;
-    FActiveTerminal = value;
-    // moved from else block of next if (ActiveTerminal) statement
-    // so ScpExplorer can update its caption
-    UpdateAppTitle();
-    if (ScpExplorer)
+    if (NonVisualDataModule != NULL)
     {
-      if (ActiveTerminal && ((ActiveTerminal->Status == ssOpened) || ActiveTerminal->Disconnected))
-      {
-        TerminalReady();
-      }
-      else
-      {
-        ScpExplorer->Terminal = NULL;
-        ScpExplorer->Queue = NULL;
-      }
+      NonVisualDataModule->StartBusy();
     }
-
-    if (PActiveTerminal != NULL)
+    try
     {
-      if (PActiveTerminal->DisconnectedTemporarily && DebugAlwaysTrue(PActiveTerminal->Disconnected))
-      {
-        PActiveTerminal->Disconnected = false;
-        PActiveTerminal->DisconnectedTemporarily = false;
-      }
+      // here used to be call to TCustomScpExporer::UpdateSessionData (now UpdateTerminal)
+      // but it seems to be duplicate to call from TCustomScpExporer::TerminalChanging
 
-      if (!PActiveTerminal->Active)
+      TManagedTerminal * PActiveTerminal = ActiveTerminal;
+      FActiveTerminal = value;
+      // moved from else block of next if (ActiveTerminal) statement
+      // so ScpExplorer can update its caption
+      UpdateAppTitle();
+      if (ScpExplorer)
       {
-        SaveTerminal(PActiveTerminal);
+        if (ActiveTerminal && ((ActiveTerminal->Status == ssOpened) || ActiveTerminal->Disconnected))
+        {
+          TerminalReady();
+        }
+        else
+        {
+          ScpExplorer->Terminal = NULL;
+          ScpExplorer->Queue = NULL;
+        }
       }
-    }
 
-    if (ActiveTerminal)
-    {
-      int Index = ActiveTerminalIndex;
-      if (!ActiveTerminal->Active && !FTerminationMessages->Strings[Index].IsEmpty())
+      if (PActiveTerminal != NULL)
       {
-        UnicodeString Message = FTerminationMessages->Strings[Index];
-        FTerminationMessages->Strings[Index] = L"";
-        if (AutoReconnect)
+        if (PActiveTerminal->DisconnectedTemporarily && DebugAlwaysTrue(PActiveTerminal->Disconnected))
         {
-          ReconnectActiveTerminal();
+          PActiveTerminal->Disconnected = false;
+          PActiveTerminal->DisconnectedTemporarily = false;
         }
-        else
+
+        if (!PActiveTerminal->Active)
         {
-          Exception * E = new ESshFatal(NULL, Message);
-          try
+          SaveTerminal(PActiveTerminal);
+        }
+      }
+
+      if (ActiveTerminal)
+      {
+        int Index = ActiveTerminalIndex;
+        if (!ActiveTerminal->Active && !FTerminationMessages->Strings[Index].IsEmpty())
+        {
+          UnicodeString Message = FTerminationMessages->Strings[Index];
+          FTerminationMessages->Strings[Index] = L"";
+          if (AutoReconnect)
           {
-            // finally show pending terminal message,
-            // this gives user also possibility to reconnect
-            ActiveTerminal->ShowExtendedException(E);
+            ReconnectActiveTerminal();
           }
-          __finally
+          else
           {
-            delete E;
+            Exception * E = new ESshFatal(NULL, Message);
+            try
+            {
+              // finally show pending terminal message,
+              // this gives user also possibility to reconnect
+              ActiveTerminal->ShowExtendedException(E);
+            }
+            __finally
+            {
+              delete E;
+            }
           }
         }
       }
-    }
-    else
-    {
-      if (OnLastTerminalClosed)
+      else
       {
-        OnLastTerminalClosed(this);
+        if (OnLastTerminalClosed)
+        {
+          OnLastTerminalClosed(this);
+        }
       }
-    }
 
 
-    if ((ActiveTerminal != NULL) && !ActiveTerminal->Active &&
-        !ActiveTerminal->Disconnected)
+      if ((ActiveTerminal != NULL) && !ActiveTerminal->Active &&
+          !ActiveTerminal->Disconnected)
+      {
+        ConnectActiveTerminal();
+      }
+    }
+    __finally
     {
-      ConnectActiveTerminal();
+      if (NonVisualDataModule != NULL)
+      {
+        NonVisualDataModule->EndBusy();
+      }
     }
   }
 }