OSDN Git Service

Fixed issue #190: Access violation in Blame and wrong path name when root dir is...
authorFrank Li <lznuaa@gmail.com>
Sun, 11 Oct 2009 06:02:15 +0000 (14:02 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 11 Oct 2009 06:02:15 +0000 (14:02 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseGitBlame/TortoiseGitBlameDoc.cpp
src/TortoiseGitBlame/TortoiseGitBlameView.cpp
src/TortoiseGitBlame/TortoiseGitBlameView.h
src/Utils/MiscUI/SciEdit.h

index 633d18e..69aeb60 100644 (file)
@@ -90,7 +90,11 @@ BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName,CString Rev)
                g_Git.m_CurrentDir=topdir;\r
 \r
                CString PathName=lpszPathName;\r
-               PathName=PathName.Right(PathName.GetLength()-g_Git.m_CurrentDir.GetLength()-1);\r
+               if(topdir[topdir.GetLength()-1] == _T('\\'))\r
+                       PathName=PathName.Right(PathName.GetLength()-g_Git.m_CurrentDir.GetLength());\r
+               else\r
+                       PathName=PathName.Right(PathName.GetLength()-g_Git.m_CurrentDir.GetLength()-1);\r
+\r
                CTGitPath path;\r
                path.SetFromWin(PathName);\r
 \r
index 7069d24..fccce3f 100644 (file)
@@ -36,6 +36,7 @@
 UINT CTortoiseGitBlameView::m_FindDialogMessage;\r
 \r
 // CTortoiseGitBlameView\r
+IMPLEMENT_DYNAMIC(CSciEditBlame,CSciEdit)\r
 \r
 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView, CView)\r
 \r
index 01a8667..48082fd 100644 (file)
@@ -36,6 +36,27 @@ const int blockSize = 128 * 1024;
 #define GET_Y_LPARAM(lp)                        ((int)(short)HIWORD(lp))\r
 #endif\r
 \r
+class CSciEditBlame: public CSciEdit\r
+{\r
+       DECLARE_DYNAMIC(CSciEditBlame)\r
+public:\r
+       afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)\r
+       {\r
+               switch (nChar)\r
+               {\r
+                       case (VK_ESCAPE):\r
+                       {\r
+                               if ((Call(SCI_AUTOCACTIVE)==0)&&(Call(SCI_CALLTIPACTIVE)==0))\r
+                               {\r
+                                       ::SendMessage(::AfxGetApp()->GetMainWnd()->m_hWnd, WM_CLOSE, 0, 0);\r
+                                       return;\r
+                               }\r
+                       }\r
+                       break;\r
+               }\r
+               CWnd::OnKeyDown(nChar, nRepCnt, nFlags);\r
+       }\r
+};\r
 \r
 class CTortoiseGitBlameView : public CView\r
 {\r
@@ -111,7 +132,7 @@ public:
        void UpdateInfo();\r
        void FocusOn(GitRev *pRev);\r
 \r
-       CSciEdit                        m_TextView;\r
+       CSciEditBlame           m_TextView;\r
        CBalloon                        m_ToolTip;\r
 \r
        HINSTANCE hInstance;\r
index 5678f50..7c6bb9e 100644 (file)
@@ -145,7 +145,7 @@ protected:
        DWORD           GetStyleAt(int pos) { return (DWORD)Call(SCI_GETSTYLEAT, pos) & 0x1f; }\r
        bool            IsUrl(const CStringA& sText);\r
 \r
-       afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\r
+       virtual afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\r
        afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);\r
        DECLARE_MESSAGE_MAP()\r
 };\r