Browse Source

Remove ATL (part two)

Use std::lock_guard instead of CComCritSecLock<CComAutoCriticalSection>

 Close #4320
pull/6093/head
Don HO 5 years ago
parent
commit
3439071c3c
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
  1. 1
      PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp
  2. 5
      PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h
  3. 3
      PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp
  4. 10
      PowerEditor/src/WinControls/ReadDirectoryChanges/ThreadSafeQueue.h

1
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 <process.h>
#include "ReadDirectoryChanges.h"
#include "ReadDirectoryChangesPrivate.h"

5
PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h

@ -40,11 +40,6 @@
#endif
#include <windows.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include <atlbase.h>
#include <vector>
#include <list>

3
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 <shlwapi.h>
#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'~'))

10
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 <list>
#include <mutex>
template <typename C>
class CThreadSafeQueue : protected std::list<C>
@ -53,7 +56,7 @@ public:
void push(C& c)
{
{
CComCritSecLock<CComAutoCriticalSection> lock(m_Crit, true);
std::lock_guard<std::mutex> lock(m_mutex);
Base::push_back(c);
}
::SetEvent(m_hEvent);
@ -61,7 +64,7 @@ public:
bool pop(C& c)
{
CComCritSecLock<CComAutoCriticalSection> lock( m_Crit, true );
std::lock_guard<std::mutex> lock(m_mutex);
if (Base::empty())
{
return false;
@ -77,6 +80,5 @@ public:
protected:
HANDLE m_hEvent;
CComAutoCriticalSection m_Crit;
std::mutex m_mutex;
};

Loading…
Cancel
Save