瀏覽代碼

- Added retry when saving clips if no clips are on the clipboard that we want, was seeing times when we weren't finding any clips even though they were there, thinking it was a race condition
- Updated icons

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

sabrogden 14 年之前
父節點
當前提交
d7888ba427
共有 11 個文件被更改,包括 56 次插入25 次删除
  1. 16 12
      CP_Main.cpp
  2. 1 1
      CP_Main.rc
  3. 1 0
      CP_Main.vcxproj
  4. 9 9
      CP_Main_10.sln
  5. 1 1
      Clip.cpp
  6. 19 1
      CopyThread.cpp
  7. 2 1
      DatabaseUtilities.cpp
  8. 5 0
      Options.cpp
  9. 2 0
      Options.h
  10. 二進制
      res/Ditto2.ico
  11. 二進制
      res/Ditto2_NoCopyCb.ico

+ 16 - 12
CP_Main.cpp

@@ -327,23 +327,27 @@ void CCP_MainApp::AfterMainCreate()
 
 void CCP_MainApp::LoadGlobalClips()
 {
-	CppSQLite3Query q = m_db.execQuery(_T("SELECT lID, lShortCut, mText FROM Main WHERE lShortCut > 0 AND globalShortCut = 1"));
-
-	while(q.eof() == false)
+	try
 	{
-		int id = q.getIntField(_T("lID"));
-		int shortcut = q.getIntField(_T("lShortCut"));
-		CString desc = q.getStringField(_T("mText"));
+		CppSQLite3Query q = m_db.execQuery(_T("SELECT lID, lShortCut, mText FROM Main WHERE lShortCut > 0 AND globalShortCut = 1"));
 
-		//Constructor will add to a global list and free
-		CHotKey* globalHotKey = new CHotKey(desc, shortcut, true);
-		if(globalHotKey != NULL)
+		while(q.eof() == false)
 		{
-			globalHotKey->m_clipId = id;
-		}
+			int id = q.getIntField(_T("lID"));
+			int shortcut = q.getIntField(_T("lShortCut"));
+			CString desc = q.getStringField(_T("mText"));
+
+			//Constructor will add to a global list and free
+			CHotKey* globalHotKey = new CHotKey(desc, shortcut, true);
+			if(globalHotKey != NULL)
+			{
+				globalHotKey->m_clipId = id;
+			}
 
-		q.nextRow();
+			q.nextRow();
+		}
 	}
+	CATCH_SQLITE_EXCEPTION
 }
 
 void CCP_MainApp::StartStopServerThread()

+ 1 - 1
CP_Main.rc

@@ -67,7 +67,7 @@ END
 // remains consistent on all systems.
 IDR_MAINFRAME           ICON                    "res\\Ditto2.ico"
 IDR_CP_MAITYPE          ICON                    "res\\CP_MainDoc.ico"
-IDI_DITTO_NOCOPYCB      ICON                    "res\\Ditto_NoCopyCb.ico"
+IDI_DITTO_NOCOPYCB      ICON                    "res\\Ditto2_NoCopyCb.ico"
 
 /////////////////////////////////////////////////////////////////////////////
 //

+ 1 - 0
CP_Main.vcxproj

@@ -1865,6 +1865,7 @@
     <None Include="res\CP_Main.rc2" />
     <None Include="res\CP_MainDoc.ico" />
     <None Include="res\Ditto.ico" />
+    <None Include="res\Ditto2_NoCopyCb.ico" />
     <None Include="res\DittoNew.ico" />
     <None Include="res\Ditto_NoCopyCb.ico" />
     <None Include="res\mainfram.bmp" />

+ 9 - 9
CP_Main_10.sln

@@ -1,6 +1,6 @@
 Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CP_Main", "CP_Main.vcxproj", "{0A5F01DA-B380-194A-CA95-2CB4AB05B338}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CP_Main", "CP_Main.vcxproj", "{D90F6EAF-861C-0A85-1208-EF129A0A92E9}"
 	ProjectSection(ProjectDependencies) = postProject
 		{F08A8736-1116-4166-AF88-CF533E41E958} = {F08A8736-1116-4166-AF88-CF533E41E958}
 		{CF8F6379-5340-4494-8E59-2807ADF37B95} = {CF8F6379-5340-4494-8E59-2807ADF37B95}
@@ -21,14 +21,14 @@ Global
 		Release|x64 = Release|x64
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Debug|Win32.ActiveCfg = Debug|Win32
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Debug|Win32.Build.0 = Debug|Win32
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Debug|x64.ActiveCfg = Debug|x64
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Debug|x64.Build.0 = Debug|x64
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Release|Win32.ActiveCfg = Release|Win32
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Release|Win32.Build.0 = Release|Win32
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Release|x64.ActiveCfg = Release|x64
-		{0A5F01DA-B380-194A-CA95-2CB4AB05B338}.Release|x64.Build.0 = Release|x64
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Debug|Win32.ActiveCfg = Debug|Win32
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Debug|Win32.Build.0 = Debug|Win32
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Debug|x64.ActiveCfg = Debug|x64
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Debug|x64.Build.0 = Debug|x64
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Release|Win32.ActiveCfg = Release|Win32
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Release|Win32.Build.0 = Release|Win32
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Release|x64.ActiveCfg = Release|x64
+		{D90F6EAF-861C-0A85-1208-EF129A0A92E9}.Release|x64.Build.0 = Release|x64
 		{CF8F6379-5340-4494-8E59-2807ADF37B95}.Debug|Win32.ActiveCfg = Debug|Win32
 		{CF8F6379-5340-4494-8E59-2807ADF37B95}.Debug|Win32.Build.0 = Debug|Win32
 		{CF8F6379-5340-4494-8E59-2807ADF37B95}.Debug|x64.ActiveCfg = Debug|x64

+ 1 - 1
Clip.cpp

@@ -417,7 +417,7 @@ bool CClip::LoadFromClipboard(CClipTypes* pClipTypes)
 	
 	if(m_Formats.GetSize() == 0)
 	{
-		Log(_T("Not clip types were in supported types array"));
+		Log(_T("No clip types were in supported types array"));
 		return false;
 	}
 

+ 19 - 1
CopyThread.cpp

@@ -101,7 +101,25 @@ void CCopyThread::OnClipboardChange()
 
 	Log(_T("LoadFromClipboard - Before"));
 	bool bResult = pClip->LoadFromClipboard(pSupportedTypes);
-	Log(_T("LoadFromClipboard - End"));
+	Log(_T("LoadFromClipboard - After"));
+
+	if(!bResult)
+	{
+		DWORD delay = CGetSetOptions::GetNoFormatsRetryDelay();
+		if(delay > 0)
+		{
+			Log(StrF(_T("LoadFromClipboard didn't find any clips to save, sleeping %dms, then trying again"), delay));
+			Sleep(delay);
+
+			Log(_T("LoadFromClipboard #2 - Before"));
+			bResult = pClip->LoadFromClipboard(pSupportedTypes);
+			Log(_T("LoadFromClipboard #2 - After"));
+		}
+		else
+		{
+			Log(_T("LoadFromClipboard didn't find any clips to save, retry setting is not set, not retrying"));
+		}
+	}
 
 	if(bDeleteMemory)
 	{

+ 2 - 1
DatabaseUtilities.cpp

@@ -365,7 +365,8 @@ BOOL CreateDB(CString csFile)
 								_T("lParentID INTEGER, ")
 								_T("QuickPasteText TEXT, ")
 								_T("clipOrder REAL, ")
-								_T("clipGroupOrder REAL);"));
+								_T("clipGroupOrder REAL, ")
+								_T("globalShortCut INTEGER);"));
 
 		db.execDML(_T("CREATE TABLE Data(")
 							_T("lID INTEGER PRIMARY KEY AUTOINCREMENT, ")

+ 5 - 0
Options.cpp

@@ -1984,4 +1984,9 @@ CString CGetSetOptions::GetCopyAppExclude()
 CString CGetSetOptions::GetCopyAppSeparator()
 {
 	return GetProfileString(_T("CopyAppSeparator"), ";");
+}
+
+DWORD CGetSetOptions::GetNoFormatsRetryDelay()
+{
+	return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
 }

+ 2 - 0
Options.h

@@ -406,6 +406,8 @@ public:
 	static CString  GetCopyAppExclude();
 
 	static CString  GetCopyAppSeparator();
+
+	static DWORD	GetNoFormatsRetryDelay();
 };
 
 // global for easy access and for initialization of fast access variables

二進制
res/Ditto2.ico


二進制
res/Ditto2_NoCopyCb.ico