Browse Source

Removed GetTickCount64, didn't work on pre vista machines.
check for portable only based on if the portable file is in the directory

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@606 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 14 years ago
parent
commit
9ec9fe6fc9
4 changed files with 41 additions and 9 deletions
  1. 5 1
      MainFrm.cpp
  2. 22 1
      Misc.cpp
  3. 11 7
      Options.cpp
  4. 3 0
      Options.h

+ 5 - 1
MainFrm.cpp

@@ -148,6 +148,10 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
     SetTimer(REMOVE_OLD_REMOTE_COPIES, ONE_DAY, 0);
     SetTimer(REMOVE_OLD_ENTRIES_TIMER, ONE_MINUTE*15, 0);
 
+	//found on some computers GetTickCount gettickcount returns a smaller value than other, can't explain
+	//check here to see if we need to make an adjustment
+	IdleSeconds();
+
     m_ulCopyGap = CGetSetOptions::GetCopyGap();
 
     theApp.AfterMainCreate();
@@ -476,7 +480,7 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
 			break;
 
         case REMOVE_OLD_ENTRIES_TIMER:
-            {
+			{
                 m_thread.FireDeleteEntries();
             }
 			break;

+ 22 - 1
Misc.cpp

@@ -132,12 +132,33 @@ CString GetErrorString( int err )
 	return str;
 }
 
+int g_funnyGetTickCountAdjustment = -1;
+
 DWORD IdleSeconds()
 {
 	LASTINPUTINFO info; 
 	info.cbSize = sizeof(info);
 	GetLastInputInfo(&info);   
-	ULONGLONG currentTick  = GetTickCount64();
+	DWORD currentTick  = GetTickCount();
+
+	if(g_funnyGetTickCountAdjustment == -1)
+	{
+		if(currentTick < info.dwTime)
+		{
+			g_funnyGetTickCountAdjustment = 1;
+		}
+		else
+		{
+			g_funnyGetTickCountAdjustment = 0;
+		}		
+	}
+	
+	if(g_funnyGetTickCountAdjustment == 1)
+	{
+		Log(StrF(_T("Adjusting time of get tickcount by: %d, on startup we found GetTickCount to be less than last input"), CGetSetOptions::GetFunnyTickCountAdjustment()));
+		currentTick += CGetSetOptions::GetFunnyTickCountAdjustment();
+	}
+
 	DWORD idleSeconds = (currentTick - info.dwTime)/1000;
 
 	return idleSeconds;

+ 11 - 7
Options.cpp

@@ -59,6 +59,7 @@ bool CGetSetOptions::m_bOutputDebugString;
 bool CGetSetOptions::m_bU3 = false;
 bool CGetSetOptions::m_bInConversion = false;
 bool CGetSetOptions::m_bFromIni = false;
+bool CGetSetOptions::m_portable = false;
 CString CGetSetOptions::m_csIniFileName;
 __int64 CGetSetOptions::nLastDbWriteTime = 0;
 CTheme CGetSetOptions::m_Theme;
@@ -93,14 +94,13 @@ void CGetSetOptions::LoadSettings()
 		{
 			CString portable = GetFilePath(m_csIniFileName);
 			portable += _T("portable");
-			if(FileExists(portable))
+			if(FileExists(portable)) 
 			{
 				m_bFromIni = true;
+				m_portable = true;
 
 				//local ini file doesn't exist but portable file does, create the ini file with defaults
 				//This is done so they can copy the entire directory for portable zip files and not overright there settings file
-				SetProfileLong(_T("SetCurrentDirectory"), 1);
-				SetProfileLong(_T("Portable"), 1);
 				SetProfileLong(_T("DisableRecieve"), 1);
 				SetProfileLong(_T("CheckForMaxEntries"), 1);
 				SetProfileLong(_T("MaxEntries"), 100);
@@ -1812,20 +1812,19 @@ void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
 
 BOOL CGetSetOptions::GetSetCurrentDirectory()
 {
-	BOOL bRet = GetProfileLong(_T("SetCurrentDirectory"), FALSE);
-	if(bRet)
+	if(m_portable)
 	{
 		CString csExePath = GetFilePath(GetExeFileName());
 		FIX_CSTRING_PATH(csExePath);
 		::SetCurrentDirectory(csExePath);
 	}
 
-	return bRet;
+	return m_portable == true;
 }
 
 bool CGetSetOptions::GetIsPortableDitto()
 {
-	return GetProfileLong(_T("Portable"), FALSE) == TRUE;
+	return m_portable;
 }
 
 CString CGetSetOptions::GetPasteString(CString csAppName)
@@ -2022,4 +2021,9 @@ DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
 DWORD CGetSetOptions::GetDbTimeout()
 {  
 	return GetProfileLong(_T("DbTimeout"), 5000);
+}
+
+DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
+{  
+	return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
 }

+ 3 - 0
Options.h

@@ -71,6 +71,7 @@ public:
 	static bool m_bInConversion;
 	static bool m_bU3;
 	static CTheme m_Theme;
+	static bool m_portable;
 
 	static void LoadSettings();
 	static CString GetIniFileName(bool bLocalIniFile);
@@ -414,6 +415,8 @@ public:
 	static DWORD	GetIdleSecondsBeforeDelete();
 
 	static DWORD	GetDbTimeout();
+
+	static DWORD	GetFunnyTickCountAdjustment();
 };
 
 // global for easy access and for initialization of fast access variables