Explorar o código

Issue 2283 – Failure when closing the last remote tab

https://winscp.net/tracker/2283
(cherry picked from commit a5152c6eb8d484f21988e3a06a2a10cb109aa605)

Source commit: 120c4eb7a5aec57c5e9980cf7a1bd8511355e3c0
Martin Prikryl hai 1 ano
pai
achega
4f1ba5aa5d
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      source/forms/ScpCommander.cpp

+ 5 - 3
source/forms/ScpCommander.cpp

@@ -2291,15 +2291,17 @@ void __fastcall TScpCommanderForm::DoLocalPathComboBoxAdjustImageIndex(
   if (FLocalPathComboBoxPaths != NULL)
   {
     TTBXComboBoxItem * PathComboBox = DebugNotNull(dynamic_cast<TTBXComboBoxItem *>(Sender));
-    DebugAssert(FLocalPathComboBoxPaths->Count == PathComboBox->Strings->Count);
-    DebugAssert(AIndex < FLocalPathComboBoxPaths->Count);
+    DebugAssert(FSessionChanging || (FLocalPathComboBoxPaths->Count == PathComboBox->Strings->Count));
+    DebugAssert(FSessionChanging || (AIndex < FLocalPathComboBoxPaths->Count));
 
     if (AIndex < 0)
     {
       AIndex = PathComboBox->ItemIndex;
     }
 
-    if (AIndex >= 0)
+    // We might get called via some Windows messages while switching from remote to local tab (FSessionChanging),
+    // before the UpdateRemotePathComboBox gets called. If that happens, ignore the call.
+    if ((AIndex >= 0) && (AIndex < FLocalPathComboBoxPaths->Count))
     {
       ImageIndex = int(FLocalPathComboBoxPaths->Objects[AIndex]);
     }