1
0
Эх сурвалжийг харах

Correcting implementation of StartupSeconds* counters + RunsNormal counter

(cherry picked from commit a8ab00b400effb312079f441a061a22e6ea99c04)

# Conflicts:
#	source/forms/ScpCommander.cpp

Source commit: 95fc2b98646fd947c47a4215a8fb456db9b5c804
Martin Prikryl 5 жил өмнө
parent
commit
0d4ac03109

+ 7 - 6
source/forms/CustomScpExplorer.cpp

@@ -4653,12 +4653,6 @@ void __fastcall TCustomScpExplorerForm::Idle()
           RemoteDirView->ReloadDirectory();
         }
       }
-
-      if (!FStarted)
-      {
-        FStarted = true;
-        InterfaceStarted();
-      }
     }
   }
 
@@ -9196,6 +9190,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),

+ 1 - 0
source/windows/TerminalManager.cpp

@@ -956,6 +956,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

@@ -533,6 +533,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)
                   {