瀏覽代碼

Bug 2040: Configuration import did not remove old sites and did not load all GUI settings

https://winscp.net/tracker/2040
(cherry picked from commit 11b621e3d3678b486e338a5b870a81056eb48d3f)

Source commit: 4a09a70f20d3199b8609fe5ebb2e2a2001f22a2e
Martin Prikryl 4 年之前
父節點
當前提交
d828f599e8
共有 5 個文件被更改,包括 12 次插入10 次删除
  1. 4 0
      source/core/Configuration.cpp
  2. 5 8
      source/forms/Login.cpp
  3. 1 0
      source/forms/Preferences.cpp
  4. 1 1
      source/resource/TextsWin.h
  5. 1 1
      source/resource/TextsWin1.rc

+ 4 - 0
source/core/Configuration.cpp

@@ -405,6 +405,8 @@ void __fastcall TConfiguration::Import(const UnicodeString & FileName)
     Default();
     LoadFrom(ImportStorage);
 
+    Storage->RecursiveDeleteSubKey(Configuration->StoredSessionsSubKey);
+
     if (ImportStorage->OpenSubKey(Configuration->StoredSessionsSubKey, false))
     {
       StoredSessions->Clear();
@@ -420,6 +422,8 @@ void __fastcall TConfiguration::Import(const UnicodeString & FileName)
 
   // save all and explicit
   DoSave(true, true);
+
+  FDontSave = true;
 }
 //---------------------------------------------------------------------------
 void __fastcall TConfiguration::LoadData(THierarchicalStorage * Storage)

+ 5 - 8
source/forms/Login.cpp

@@ -2641,7 +2641,7 @@ void __fastcall TLoginDialog::ExportActionExecute(TObject * /*Sender*/)
 //---------------------------------------------------------------------------
 void __fastcall TLoginDialog::ImportActionExecute(TObject * /*Sender*/)
 {
-  if (MessageDialog(MainInstructions(LoadStr(IMPORT_CONFIGURATION)),
+  if (MessageDialog(LoadStr(IMPORT_CONFIGURATION2),
         qtWarning, qaOK | qaCancel, HELP_IMPORT_CONFIGURATION) == qaOK)
   {
     std::unique_ptr<TOpenDialog> OpenDialog(new TOpenDialog(Application));
@@ -2652,15 +2652,12 @@ void __fastcall TLoginDialog::ImportActionExecute(TObject * /*Sender*/)
 
     if (OpenDialog->Execute())
     {
-      // before the session list gets destroyed
+      // Before the session list gets destroyed
       SessionTree->Items->Clear();
       Configuration->Import(OpenDialog->FileName);
-      ReloadSessions(L"");
-
-      if (SessionTree->Items->Count > 0)
-      {
-        SessionTree->Items->GetFirstNode()->MakeVisible();
-      }
+      // Similar to TPreferencesDialog::CustomIniFileStorageChanged
+      ExecuteSelf(EmptyStr);
+      TerminateApplication();
     }
   }
 }

+ 1 - 0
source/forms/Preferences.cpp

@@ -3047,6 +3047,7 @@ void __fastcall TPreferencesDialog::CustomIniFileStorageChanged()
     }
     else if (Result == qaNo)
     {
+      // Similar to TLoginDialog::ImportActionExecute
       Configuration->ScheduleCustomIniFileStorageUse(GetCustomIniFileStorageName());
       ExecuteNewInstance(L"");
       TerminateApplication();

+ 1 - 1
source/resource/TextsWin.h

@@ -144,7 +144,7 @@
 #define CLOSE_SESSIONS_WORKSPACE3 1355
 #define EDITOR_AUTO_CONFIG2     1356
 #define IMPORT_SESSIONS2        1357
-#define IMPORT_CONFIGURATION    1358
+#define IMPORT_CONFIGURATION2    1358
 #define ALL_BUTTON              1359
 #define YES_TO_ALL_BUTTON       1360
 #define REPORT_BUTTON           1361

+ 1 - 1
source/resource/TextsWin1.rc

@@ -148,7 +148,7 @@ BEGIN
         EDIT_SESSION_RECONNECT, "Do you want to reconnect session '%s' to upload edited file '%s'?"
         CLOSE_SESSIONS_WORKSPACE3, "Terminate all sessions and close application without saving a workspace?"
         IMPORT_SESSIONS2, "**You have stored sessions/sites in %s.\n\nDo you want to import them into WinSCP?**\n\n(You can import them anytime later from Login dialog)|PuTTY SSH client|FileZilla FTP client|%s and %s"
-        IMPORT_CONFIGURATION, "Importing configuration will overwrite all your preferences and sites.\n\nDo you want to continue?"
+        IMPORT_CONFIGURATION2, "**Restore configuration from a backup?**\n\nImporting configuration will overwrite all your preferences and sites. WinSCP will be restarted with the new configuration. Consider saving your work and creating backup of your current configuration."
         ALL_BUTTON, "A&ll"
         YES_TO_ALL_BUTTON, "Yes to A&ll"
         REPORT_BUTTON, "Re&port"