OSDN Git Service

Add multi-thread protection and correct log info label
authorFrank Li <lznuaa@gmail.com>
Tue, 12 Jan 2010 02:12:27 +0000 (10:12 +0800)
committerFrank Li <lznuaa@gmail.com>
Tue, 12 Jan 2010 02:12:27 +0000 (10:12 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/LogDlg.cpp

index f4b7cd5..188c70f 100644 (file)
@@ -74,6 +74,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
 \r
        m_IsIDReplaceAction=FALSE;\r
 \r
 \r
        m_IsIDReplaceAction=FALSE;\r
 \r
+       this->m_critSec.Init();\r
        m_wcRev.m_CommitHash.Empty();\r
        m_wcRev.m_Subject=_T("Working dir changes");\r
        m_wcRev.m_ParentHash.clear();\r
        m_wcRev.m_CommitHash.Empty();\r
        m_wcRev.m_Subject=_T("Working dir changes");\r
        m_wcRev.m_ParentHash.clear();\r
@@ -2096,8 +2097,7 @@ UINT CGitLogListBase::LogThread()
 \r
                CGitHash hash = (char*)commit.m_hash ;\r
 \r
 \r
                CGitHash hash = (char*)commit.m_hash ;\r
 \r
-               m_logEntries.push_back(hash);\r
-               \r
+                       \r
                GitRev *pRev = m_LogCache.GetCacheData(hash);\r
                \r
                if(pRev == NULL || !pRev->m_IsFull)\r
                GitRev *pRev = m_LogCache.GetCacheData(hash);\r
                \r
                if(pRev == NULL || !pRev->m_IsFull)\r
@@ -2114,9 +2114,12 @@ UINT CGitLogListBase::LogThread()
                        pRev->ParserParentFromCommit(&commit);\r
                }\r
 \r
                        pRev->ParserParentFromCommit(&commit);\r
                }\r
 \r
+               this->m_critSec.Lock();\r
+               m_logEntries.push_back(hash);\r
                m_arShownList.Add(pRev);\r
                m_arShownList.Add(pRev);\r
+               this->m_critSec.Unlock();\r
 \r
 \r
-               if(t2-t1>500 && m_logEntries.size()>(oldsize+100) )\r
+               if(t2-t1>500 )\r
                {\r
                        //update UI\r
                        oldsize = m_logEntries.size();\r
                {\r
                        //update UI\r
                        oldsize = m_logEntries.size();\r
index ceaebbb..76564fb 100644 (file)
@@ -243,6 +243,8 @@ protected:
 \r
        int GetHeadIndex();\r
 \r
 \r
        int GetHeadIndex();\r
 \r
+       CComCriticalSection                     m_critSec;\r
+\r
        bool                            m_bFilterWithRegex;\r
 \r
        \r
        bool                            m_bFilterWithRegex;\r
 \r
        \r
index 9c29a18..41e84bf 100644 (file)
@@ -375,8 +375,9 @@ LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
                if(this->m_LogList.HasText())\r
                {\r
                        this->m_LogList.ClearText();\r
                if(this->m_LogList.HasText())\r
                {\r
                        this->m_LogList.ClearText();\r
-                       //UpdateLogInfoLabel();\r
+                       \r
                }\r
                }\r
+               UpdateLogInfoLabel();\r
 \r
 #if 0\r
                //if (!m_bShowedAll)\r
 \r
 #if 0\r
                //if (!m_bShowedAll)\r
@@ -2518,15 +2519,18 @@ void CLogDlg::UpdateLogInfoLabel()
        git_revnum_t rev2 ;\r
        long selectedrevs = 0;\r
        int count =m_LogList.m_arShownList.GetCount();\r
        git_revnum_t rev2 ;\r
        long selectedrevs = 0;\r
        int count =m_LogList.m_arShownList.GetCount();\r
+       int start = 0;\r
        if (count)\r
        {\r
        if (count)\r
        {\r
-               rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;\r
+               if(this->m_LogList.m_bShowWC)\r
+                       start = 1;\r
+               rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(start)))->m_CommitHash;\r
                //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));\r
                rev2 =  (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;\r
                selectedrevs = m_LogList.GetSelectedCount();\r
        }\r
        CString sTemp;\r
                //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));\r
                rev2 =  (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;\r
                selectedrevs = m_LogList.GetSelectedCount();\r
        }\r
        CString sTemp;\r
-       sTemp.Format(_T("Showing %ld revision(s), from revision %s to revision %s - %ld revision(s) selected"), count, rev2.Left(6), rev1.Left(6), selectedrevs);\r
+       sTemp.Format(_T("Showing %ld revision(s), from revision %s to revision %s - %ld revision(s) selected"), count - start, rev2.Left(6), rev1.Left(6), selectedrevs);\r
        m_sLogInfo = sTemp;\r
 \r
        UpdateData(FALSE);\r
        m_sLogInfo = sTemp;\r
 \r
        UpdateData(FALSE);\r