CDiffThread::CDiffThread()
{
m_pDiffContext = NULL;
+ m_thread = NULL;
+ diffParam.nThreadState = THREAD_NOTSTARTED;
}
CDiffThread::~CDiffThread()
}
-CDiffContext * CDiffThread::SetContext( CDiffContext * pCtx )
+CDiffContext * CDiffThread::SetContext(CDiffContext * pCtx)
{
CDiffContext *pTempContext = m_pDiffContext;
m_pDiffContext = pCtx;
return pTempContext;
}
-UINT CDiffThread::CompareDirectories( CString dir1, CString dir2 )
+UINT CDiffThread::CompareDirectories(CString dir1, CString dir2)
{
diffParam.path1 = dir1;
diffParam.path2 = dir2;
diffParam.context = m_pDiffContext;
diffParam.msgUIUpdate = m_msgUpdateUI;
- diffParam.window = m_hWnd;
+ diffParam.hWindow = m_hWnd;
- CWinThread *thread = AfxBeginThread(DiffThread, (LPVOID)&diffParam);
+ diffParam.nThreadState = THREAD_COMPARING;
+ m_thread = AfxBeginThread(DiffThread, (LPVOID)&diffParam);
return 1;
}
-void CDiffThread::SetHwnd( HWND hWnd )
+void CDiffThread::SetHwnd(HWND hWnd)
{
m_hWnd = hWnd;
}
m_msgUpdateStatus = statusMsg;
}
-UINT DiffThread( LPVOID lpParam )
+UINT CDiffThread::GetThreadState()
+{
+ return diffParam.nThreadState;
+}
+
+UINT DiffThread(LPVOID lpParam)
{
DiffFuncStruct *myStruct = (DiffFuncStruct *) lpParam;
- HWND hWnd = myStruct->window;
+ HWND hWnd = myStruct->hWindow;
UINT msgID = myStruct->msgUIUpdate;
compare_files (0, (char const *)(LPCTSTR)myStruct->path1,
myStruct->context, 0);
// Send message to UI to update
+ diffParam.nThreadState = THREAD_COMPLETED;
SendMessage(hWnd, msgID, NULL, NULL);
return 1;
}
#include "diffcontext.h"
+enum
+{
+ THREAD_NOTSTARTED = 0,
+ THREAD_COMPARING,
+ THREAD_COMPLETED
+};
+
struct DiffFuncStruct
{
CString path1;
CDiffContext * context;
UINT msgUIUpdate;
UINT msgStatusUpdate;
- HWND window;
+ HWND hWindow;
+ UINT nThreadState;
};
class CDiffThread
UINT CompareDirectories(CString dir1, CString dir2);
void SetHwnd(HWND hWnd);
void SetMessageIDs(UINT updateMsg, UINT statusMsg);
+ UINT GetThreadState();
private:
CDiffContext * m_pDiffContext;
+ CWinThread * m_thread;
UINT m_msgUpdateUI;
UINT m_msgUpdateStatus;
HWND m_hWnd;
CString s;
AfxFormatString2(s, IDS_DIRECTORY_WINDOW_STATUS_FMT, m_pCtxt->m_strLeft, m_pCtxt->m_strRight);
((CDirFrame*)(m_pDirView->GetParent()))->SetStatus(s);
+
+ // Needed to clear display
+ Redisplay();
}
// return true if we need to hide this item because it is a backup
void SetDirView( CDirView *newView ); // TODO Perry
void AddMergeDoc(CMergeDoc * pMergeDoc);
void MergeDocClosing(CMergeDoc * pMergeDoc);
+ CDiffThread m_diffThread;
#ifdef _DEBUG
virtual void AssertValid() const;
// Implementation data
private:
DirDocFilter * m_pFilter;
- CDiffThread m_diffThread;
CDirView *m_pDirView;
MergeDocPtrList m_MergeDocs;
BOOL m_bReuseMergeDocs; // policy to reuse existing merge docs
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateSave)
ON_MESSAGE(MSG_UI_UPDATE, OnUpdateUIMessage)
ON_COMMAND(ID_REFRESH, OnRefresh)
+ ON_UPDATE_COMMAND_UI(ID_REFRESH, OnUpdateRefresh)
//}}AFX_MSG_MAP
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick)
END_MESSAGE_MAP()
return CListViewEx::PreTranslateMessage(pMsg);
}
-void CDirView::OnUpdateUIMessage(WPARAM wParam, LPARAM lParam )
+void CDirView::OnUpdateRefresh(CCmdUI* pCmdUI)
+{
+ UINT threadState = GetDocument()->m_diffThread.GetThreadState();
+ if (threadState == THREAD_COMPARING)
+ pCmdUI->Enable(FALSE);
+ else
+ pCmdUI->Enable(TRUE);
+}
+
+void CDirView::OnUpdateUIMessage(WPARAM wParam, LPARAM lParam)
{
GetDocument()->Redisplay();
if (mf->m_bScrollToFirst)
afx_msg void OnUpdateSave(CCmdUI* pCmdUI);
afx_msg void OnUpdateUIMessage(WPARAM wParam, LPARAM lParam);
afx_msg void OnRefresh();
+ afx_msg void OnUpdateRefresh(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
+2003-07-11 Kimmo
+ PATCH: [ 769295 ] Fix for threaded dir compare crash
+ WinMerge: DiffThread.h DiffThread.cpp DirDoc.h DirDoc.cpp DirView.h DirView.cpp
+
2003-07-10 Kimmo
PATCH: [ 766727 ] Threaded dir compare
WinMerge: DiffContext.h DiffContext.cpp DirDoc.h DirDoc.cpp