Browse Source

Renaming the LastInternalException counter to LastInternalException2 and resetting it on upgrade (or downgrade) and after usage statistics report

Source commit: 4ed6ed30ec2f5b4cb2e13c72d54611f873aa21f2
Martin Prikryl 9 years ago
parent
commit
25ede5dfb2
3 changed files with 22 additions and 1 deletions
  1. 1 1
      source/core/Exceptions.cpp
  2. 18 0
      source/core/Usage.cpp
  3. 3 0
      source/core/Usage.h

+ 1 - 1
source/core/Exceptions.cpp

@@ -165,7 +165,7 @@ static bool __fastcall ExceptionMessage(Exception * E, bool Count,
     Configuration->Usage->Inc(CounterName);
     UnicodeString ExceptionDebugInfo =
       E->ClassName() + L":" + GetExceptionDebugInfo();
-    Configuration->Usage->Set(L"LastInternalException", ExceptionDebugInfo);
+    Configuration->Usage->Set(LastInternalExceptionCounter, ExceptionDebugInfo);
   }
 
   return Result;

+ 18 - 0
source/core/Usage.cpp

@@ -9,6 +9,8 @@
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 //---------------------------------------------------------------------------
+const UnicodeString LastInternalExceptionCounter(L"LastInternalException2");
+//---------------------------------------------------------------------------
 __fastcall TUsage::TUsage(TConfiguration * Configuration)
 {
   FCriticalSection = new TCriticalSection();
@@ -160,6 +162,7 @@ void __fastcall TUsage::Reset()
   TGuard Guard(FCriticalSection);
   UpdateLastReport();
   FPeriodCounters.clear();
+  ResetLastInternalException();
 }
 //---------------------------------------------------------------------------
 void __fastcall TUsage::UpdateCurrentVersion()
@@ -181,10 +184,25 @@ void __fastcall TUsage::UpdateCurrentVersion()
     {
       Inc(L"Downgrades");
     }
+
+    if (PrevVersion != CompoundVersion)
+    {
+      ResetLastInternalException();
+    }
   }
   Set(L"CurrentVersion", CompoundVersion);
 }
 //---------------------------------------------------------------------------
+void __fastcall TUsage::ResetLastInternalException()
+{
+  TGuard Guard(FCriticalSection);
+  int Index = FValues->IndexOfName(LastInternalExceptionCounter);
+  if (Index >= 0)
+  {
+    FValues->Delete(Index);
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall TUsage::Inc(const UnicodeString & Key, int Increment)
 {
   if (Collect)

+ 3 - 0
source/core/Usage.h

@@ -51,6 +51,9 @@ private:
   void __fastcall SetMax(const UnicodeString & Key, int Value, TCounters & Counters);
   void __fastcall Serialize(UnicodeString& List,
     const UnicodeString & Name, const TCounters & Counters) const;
+  void __fastcall ResetLastInternalException();
 };
 //---------------------------------------------------------------------------
+extern const UnicodeString LastInternalExceptionCounter;
+//---------------------------------------------------------------------------
 #endif