浏览代码

Confirm closing when multiple tabs are opened and auto workspace saving is not enabled, even when none of the tabs contain an active remote session

(cherry picked from commit e7b032cd8afa93e2d044aac777277f46ab6f1246)

Source commit: 27c0332deb7af00a64060ad393fbe5f08a46ed66
Martin Prikryl 4 年之前
父节点
当前提交
c3b61c2e0c
共有 3 个文件被更改,包括 13 次插入3 次删除
  1. 11 3
      source/forms/CustomScpExplorer.cpp
  2. 1 0
      source/resource/TextsWin.h
  3. 1 0
      source/resource/TextsWin1.rc

+ 11 - 3
source/forms/CustomScpExplorer.cpp

@@ -4982,8 +4982,9 @@ void __fastcall TCustomScpExplorerForm::FormCloseQuery(TObject * /*Sender*/,
         ActiveSessions++;
       }
     }
-    // Confirm, when there's at least one active remote session
-    if ((ActiveSessions > 0) &&
+    // Confirm, when there's at least one active remote session or
+    // when there are multiple (inactive or local) sessions and auto workspace saving is not enabled.
+    if (((ActiveSessions > 0) || ((Manager->Count > 1) && !WinConfiguration->AutoSaveWorkspace)) &&
         WinConfiguration->ConfirmClosingSession)
     {
       unsigned int Result;
@@ -5004,7 +5005,7 @@ void __fastcall TCustomScpExplorerForm::FormCloseQuery(TObject * /*Sender*/,
         Message = FORMAT(Message, (Terminal->SessionData->SessionName));
       }
       // Multiple active sessions or one active session, but it's not the current one
-      else if (DebugAlwaysTrue(ActiveSessions > 0))
+      else if (ActiveSessions > 0)
       {
         if (!WinConfiguration->AutoSaveWorkspace)
         {
@@ -5015,6 +5016,13 @@ void __fastcall TCustomScpExplorerForm::FormCloseQuery(TObject * /*Sender*/,
           Message = LoadStr(CLOSE_SESSIONS);
         }
       }
+      // Multiple tabs, but all are intactive or local, and saving of worspace is not enabled
+      else
+      {
+        DebugAlwaysTrue(Manager->Count > 1);
+        DebugAlwaysTrue(!WinConfiguration->AutoSaveWorkspace);
+        Message = LoadStr(CLOSE_WORKSPACE);
+      }
 
       UnicodeString Note;
       if (WinConfiguration->AutoSaveWorkspace)

+ 1 - 0
source/resource/TextsWin.h

@@ -158,6 +158,7 @@
 #define CUSTOM_INI_FILE_OVERWRITE 1369
 #define READONLY_INI_FILE_OVERWRITE 1370
 #define CLOSE_SESSION_WORKSPACE 1371
+#define CLOSE_WORKSPACE         1372
 
 #define WIN_INFORMATION_STRINGS 1400
 #define COMPARE_NO_DIFFERENCES  1402

+ 1 - 0
source/resource/TextsWin1.rc

@@ -162,6 +162,7 @@ BEGIN
         CUSTOM_INI_FILE_OVERWRITE, "**Do you want to overwrite an existing INI file '%s'?**\n\nChoose 'Overwrite' to overwrite the selected INI file with the current configuration.\n\nChoose 'Use' to restart WinSCP with a configuration loaded from the selected INI file. Your current configuration will be preserved and you can revert to it, if needed.|&Overwrite|&Use"
         READONLY_INI_FILE_OVERWRITE, "**Do you want to overwrite a read-only INI file '%s' to save your current configuration?**This question is asked, when you hold down Shift key while closing WinSCP and your INI file is set read-only. Normally read-only INI files are not overwritten and any changes to configuration are lost when closing WinSCP."
         CLOSE_SESSION_WORKSPACE, "Terminate session '%s' and close application without saving a workspace?"
+        CLOSE_WORKSPACE, "Close application without saving a workspace?"
 
         WIN_INFORMATION_STRINGS, "WIN_INFORMATION"
         COMPARE_NO_DIFFERENCES, "No differences found."