Browse Source

fixed issue with using CTime::GetCurrent time as an int64 rather than an int as the string.Format was expecting, caused duplicate clips that were found to not be moved to the top of the list

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@642 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 13 years ago
parent
commit
27b5608bac
5 changed files with 15 additions and 14 deletions
  1. 9 8
      Clip.cpp
  2. 1 1
      CopyProperties.cpp
  3. 2 2
      DatabaseUtilities.cpp
  4. 2 2
      Misc.cpp
  5. 1 1
      ProcessPaste.cpp

+ 9 - 8
Clip.cpp

@@ -515,12 +515,16 @@ bool CClip::AddToDB(bool bCheckForDuplicates)
 			{
 				MakeLatestOrder();
 
-				theApp.m_db.execDMLEx(_T("UPDATE Main SET clipOrder = %f, lastPasteDate = %d where lID = %d;"), 
-										m_clipOrder, CTime::GetCurrentTime().GetTime(), nID);
+				CString sql;
+				
+				sql.Format(_T("UPDATE Main SET clipOrder = %f, lastPasteDate = %d where lID = %d;"), 
+								m_clipOrder, (int)CTime::GetCurrentTime().GetTime(), nID);
+
+				int ret = theApp.m_db.execDML(sql);
 
 				m_id = nID;
 
-				Log(StrF(_T("Found duplicate clip in db, Id: %d, crc: %d, NewOrder: %f"), nID, m_CRC, m_clipOrder));
+				Log(StrF(_T("Found duplicate clip in db, Id: %d, crc: %d, NewOrder: %f, Ret: %d, SQL: %s"), nID, m_CRC, m_clipOrder, ret, sql));
 
 				return true;
 			}
@@ -614,7 +618,7 @@ bool CClip::AddToMainTable()
 
 		CString cs;
 		cs.Format(_T("INSERT into Main values(NULL, %d, '%s', %d, %d, %d, %d, %d, '%s', %f, %f, %d, %d);"),
-							(long)m_Time.GetTime(),
+							(int)m_Time.GetTime(),
 							m_Desc,
 							m_shortCut,
 							m_dontAutoDelete,
@@ -625,7 +629,7 @@ bool CClip::AddToMainTable()
 							m_clipOrder,
 							m_clipGroupOrder,
 							m_globalShortCut,
-							CTime::GetCurrentTime().GetTime());
+							(int)CTime::GetCurrentTime().GetTime());
 
 		theApp.m_db.execDML(cs);
 
@@ -715,9 +719,6 @@ bool CClip::AddToDataTable()
 	return true;
 }
 
-// changes m_Time to be later than the latest clip entry in the db
-// ensures that pClip's time is not older than the last clip added
-// old times can happen on fast copies (<1 sec).
 void CClip::MakeLatestOrder()
 {
 	m_clipOrder = GetNewOrder(-1, m_id);

+ 1 - 1
CopyProperties.cpp

@@ -304,7 +304,7 @@ void CCopyProperties::LoadDataIntoCClip(CClip &Clip)
 	//don't auto delete check box is checked
 	if(m_bNeverAutoDelete)
 	{
-		Clip.m_dontAutoDelete = (long)CTime::GetCurrentTime().GetTime();
+		Clip.m_dontAutoDelete = (int)CTime::GetCurrentTime().GetTime();
 	}
 	else if(m_bNeverAutoDelete == FALSE)
 	{

+ 2 - 2
DatabaseUtilities.cpp

@@ -372,7 +372,7 @@ BOOL ValidDB(CString csPath, BOOL bUpgrade)
 
 			db.execDML(_T("ALTER TABLE Main ADD lastPasteDate INTEGER"));
 			db.execDML(_T("Update Main set lastPasteDate = lDate"));
-			db.execDMLEx(_T("Update Main set lastPasteDate = %d where lastPasteDate <= 0"), CTime::GetCurrentTime().GetTime());
+			db.execDMLEx(_T("Update Main set lastPasteDate = %d where lastPasteDate <= 0"), (int)CTime::GetCurrentTime().GetTime());
 
 			e.errorCode();
 		}
@@ -609,7 +609,7 @@ BOOL RemoveOldEntries()
 				
 				CppSQLite3Query q = db.execQueryEx(_T("SELECT lID FROM Main ")
 													_T("WHERE lastPasteDate < %d AND ")
-													_T("bIsGroup = 0 AND lShortCut = 0 AND lParentID <= 0 AND lDontAutoDelete = 0"), now.GetTime());
+													_T("bIsGroup = 0 AND lShortCut = 0 AND lParentID <= 0 AND lDontAutoDelete = 0"), (int)now.GetTime());
 
 				while(q.eof() == false)
 				{

+ 2 - 2
Misc.cpp

@@ -706,9 +706,9 @@ long NewGroupID(int parentID, CString text)
 		CString cs;
 
 		cs.Format(_T("insert into Main (lDate, mText, lDontAutoDelete, bIsGroup, lParentID) values(%d, '%s', %d, 1, %d);"),
-							(long)time.GetTime(),
+							(int)time.GetTime(),
 							text,
-							(long)time.GetTime(),
+							(int)time.GetTime(),
 							parentID);
 
 		theApp.m_db.execDML(cs);

+ 1 - 1
ProcessPaste.cpp

@@ -167,7 +167,7 @@ UINT CProcessPaste::MarkAsPastedThread(LPVOID pParam)
 
 			try
 			{
-				theApp.m_db.execDMLEx(_T("UPDATE Main SET lastPasteDate = %d where lID = %d;"), CTime::GetCurrentTime().GetTime(), pData->clipId);
+				theApp.m_db.execDMLEx(_T("UPDATE Main SET lastPasteDate = %d where lID = %d;"), (int)CTime::GetCurrentTime().GetTime(), pData->clipId);
 			}
 			CATCH_SQLITE_EXCEPTION