From 3439071c3cb6b9ce4cd57edc7c47cd8976f1eaf9 Mon Sep 17 00:00:00 2001 From: Don HO Date: Sun, 25 Aug 2019 02:09:17 +0200 Subject: [PATCH] Remove ATL (part two) Use std::lock_guard instead of CComCritSecLock Close #4320 --- .../ReadDirectoryChanges/ReadDirectoryChanges.cpp | 1 + .../ReadDirectoryChanges/ReadDirectoryChanges.h | 5 ----- .../ReadDirectoryChangesPrivate.cpp | 3 ++- .../WinControls/ReadDirectoryChanges/ThreadSafeQueue.h | 10 ++++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp index 36a5057bd..bbbf053c7 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp @@ -26,6 +26,7 @@ // http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html // See ReadMe.txt for overview information. +#include #include "ReadDirectoryChanges.h" #include "ReadDirectoryChangesPrivate.h" diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h index 1500f6d33..9a548db9e 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h @@ -40,11 +40,6 @@ #endif #include - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -#include - #include #include diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp index fcd1223f4..11f1ef391 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp @@ -26,6 +26,7 @@ // http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html // See ReadMe.txt for overview information. +#include #include "ReadDirectoryChanges.h" #include "ReadDirectoryChangesPrivate.h" @@ -152,7 +153,7 @@ void CReadChangesRequest::ProcessNotification() wstrFilename = m_wstrDirectory + wstrFilename; // If it could be a short filename, expand it. - LPCWSTR wszFilename = PathFindFileNameW(wstrFilename.c_str()); + LPCWSTR wszFilename = ::PathFindFileNameW(wstrFilename.c_str()); int len = lstrlenW(wszFilename); // The maximum length of an 8.3 filename is twelve, including the dot. if (len <= 12 && wcschr(wszFilename, L'~')) diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ThreadSafeQueue.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ThreadSafeQueue.h index 5682fa052..a74e1a65d 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ThreadSafeQueue.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ThreadSafeQueue.h @@ -26,7 +26,10 @@ // http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html // See ReadMe.txt for overview information. +#pragma once + #include +#include template class CThreadSafeQueue : protected std::list @@ -53,7 +56,7 @@ public: void push(C& c) { { - CComCritSecLock lock(m_Crit, true); + std::lock_guard lock(m_mutex); Base::push_back(c); } ::SetEvent(m_hEvent); @@ -61,7 +64,7 @@ public: bool pop(C& c) { - CComCritSecLock lock( m_Crit, true ); + std::lock_guard lock(m_mutex); if (Base::empty()) { return false; @@ -77,6 +80,5 @@ public: protected: HANDLE m_hEvent; - - CComAutoCriticalSection m_Crit; + std::mutex m_mutex; };