Преглед на файлове

Correcting implementation of StartupSeconds* counters + RunsNormal counter

Source commit: 4879b5d247789717bfba6a4a4d6f1537808c3e08
Martin Prikryl преди 5 години
родител
ревизия
a8ab00b400
променени са 5 файла, в които са добавени 30 реда и са изтрити 12 реда
  1. 7 6
      source/forms/CustomScpExplorer.cpp
  2. 5 2
      source/forms/ScpCommander.cpp
  3. 1 0
      source/windows/TerminalManager.cpp
  4. 1 0
      source/windows/WinInterface.h
  5. 16 4
      source/windows/WinMain.cpp

+ 7 - 6
source/forms/CustomScpExplorer.cpp

@@ -4704,12 +4704,6 @@ void __fastcall TCustomScpExplorerForm::Idle()
           RemoteDirView->ReloadDirectory();
         }
       }
-
-      if (!FStarted)
-      {
-        FStarted = true;
-        InterfaceStarted();
-      }
     }
   }
 
@@ -9247,6 +9241,13 @@ void __fastcall TCustomScpExplorerForm::CMShowingChanged(TMessage & Message)
 {
   TForm::Dispatch(&Message);
 
+  // Now the window is visible (TForm::Dispatch is what usually takes long, like when loading a "local" network directory)
+  if (Showing && !FStarted)
+  {
+    FStarted = true;
+    InterfaceStarted();
+  }
+
   if (Showing && (Terminal == NULL))
   {
     // When we are starting minimized (i.e. from an installer),

+ 5 - 2
source/forms/ScpCommander.cpp

@@ -2592,8 +2592,11 @@ void __fastcall TScpCommanderForm::DoRemotePathComboBoxCancel(TObject * Sender)
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::OtherLocalDirViewPathChange(TCustomDirView * Sender)
 {
-  DebugAssert(IsLocalBrowserMode());
-  DoLocalDirViewPathChange(Sender, RemotePathComboBox);
+  // should happen only when called from TScpCommanderForm::DoShow while starting connected
+  if (IsLocalBrowserMode())
+  {
+    DoLocalDirViewPathChange(Sender, RemotePathComboBox);
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::DoRemotePathComboBoxItemClick(TObject * Sender)

+ 1 - 0
source/windows/TerminalManager.cpp

@@ -955,6 +955,7 @@ void __fastcall TTerminalManager::ApplicationMessage(TMsg & Msg, bool & Handled)
 //---------------------------------------------------------------------------
 void __fastcall TTerminalManager::ApplicationModalBegin(TObject * /*Sender*/)
 {
+  InterfaceStartDontMeasure();
   NonVisualDataModule->StartBusy();
   if (ScpExplorer != NULL)
   {

+ 1 - 0
source/windows/WinInterface.h

@@ -543,6 +543,7 @@ UnicodeString DumpCallstackFileName(int ProcessId);
 
 void CheckConfigurationForceSave();
 void InterfaceStarted();
+void InterfaceStartDontMeasure();
 //---------------------------------------------------------------------------
 #define HIDDEN_WINDOW_NAME L"WinSCPHiddenWindow3"
 //---------------------------------------------------------------------------

+ 16 - 4
source/windows/WinMain.cpp

@@ -408,12 +408,17 @@ static UnicodeString ColorToRGBStr(TColor Color)
 TDateTime Started(Now());
 int LifetimeRuns = -1;
 //---------------------------------------------------------------------------
+void InterfaceStartDontMeasure()
+{
+  Started = TDateTime();
+}
+//---------------------------------------------------------------------------
 void InterfaceStarted()
 {
-  // deliberate downcast
-  int StartupSeconds = static_cast<int>(SecondsBetween(Now(), Started));
-  if (LifetimeRuns > 0)
+  if ((Started != TDateTime()) && (LifetimeRuns > 0))
   {
+    // deliberate downcast
+    int StartupSeconds = static_cast<int>(SecondsBetween(Now(), Started));
     if (LifetimeRuns == 1)
     {
       Configuration->Usage->Set(L"StartupSeconds1", StartupSeconds);
@@ -428,7 +433,7 @@ void InterfaceStarted()
 //---------------------------------------------------------------------------
 void __fastcall UpdateStaticUsage()
 {
-  LifetimeRuns = Configuration->Usage->Inc(L"Runs");
+  Configuration->Usage->Inc(L"Runs");
 
   Configuration->Usage->UpdateCurrentVersion();
 
@@ -1229,6 +1234,13 @@ int __fastcall Execute()
                     Download(TerminalManager->ActiveTerminal, DownloadFile,
                       UseDefaults);
                   }
+                  else
+                  {
+                    if (DataList->Count == 0)
+                    {
+                      LifetimeRuns = Configuration->Usage->Inc(L"RunsNormal");
+                    }
+                  }
 
                   if (Browse)
                   {