Skip to content

Commit 463bdc5

Browse files
committed
avoid dependency to atl, problaby not available with mingw, because of
In file included from ../src/NppIO.cpp:36:0: ../src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h:46:21: fatal error: atlbase.h: No such file or directory compilation terminated. makefile:260: recipe for target '../src/NppIO.o' failed mingw32-make: *** [../src/NppIO.o] Error 1 Command exited with code 2
1 parent 3cdd03c commit 463bdc5

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

PowerEditor/src/NppIO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
8181
// We've received a notification in the queue.
8282
{
8383
DWORD dwAction;
84-
CStringW wstrFilename;
84+
generic_string wstrFilename;
8585
if (changes.CheckOverflow())
8686
printStr(L"Queue overflowed.");
8787
else
8888
{
8989
changes.Pop(dwAction, wstrFilename);
90-
generic_string fn = wstrFilename.GetString();
90+
generic_string fn = wstrFilename;
9191

9292
// Fix monitoring files which are under root problem
9393
size_t pos = fn.find(TEXT("\\\\"));

PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ DWORD WINAPI FolderUpdater::watching(void *params)
14651465
// We've received a notification in the queue.
14661466
{
14671467
DWORD dwAction;
1468-
CStringW wstrFilename;
1468+
generic_string wstrFilename;
14691469
if (changes.CheckOverflow())
14701470
printStr(L"Queue overflowed.");
14711471
else
@@ -1478,14 +1478,14 @@ DWORD WINAPI FolderUpdater::watching(void *params)
14781478
switch (dwAction)
14791479
{
14801480
case FILE_ACTION_ADDED:
1481-
file2Change.push_back(wstrFilename.GetString());
1481+
file2Change.push_back(wstrFilename);
14821482
//thisFolderUpdater->updateTree(dwAction, file2Change);
14831483
::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_ADDFILE, reinterpret_cast<WPARAM>(nullptr), reinterpret_cast<LPARAM>(&file2Change));
14841484
oldName = TEXT("");
14851485
break;
14861486

14871487
case FILE_ACTION_REMOVED:
1488-
file2Change.push_back(wstrFilename.GetString());
1488+
file2Change.push_back(wstrFilename);
14891489
//thisFolderUpdater->updateTree(dwAction, file2Change);
14901490
::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RMFILE, reinterpret_cast<WPARAM>(nullptr), reinterpret_cast<LPARAM>(&file2Change));
14911491
oldName = TEXT("");
@@ -1496,14 +1496,14 @@ DWORD WINAPI FolderUpdater::watching(void *params)
14961496
break;
14971497

14981498
case FILE_ACTION_RENAMED_OLD_NAME:
1499-
oldName = wstrFilename.GetString();
1499+
oldName = wstrFilename;
15001500
break;
15011501

15021502
case FILE_ACTION_RENAMED_NEW_NAME:
15031503
if (not oldName.empty())
15041504
{
15051505
file2Change.push_back(oldName);
1506-
file2Change.push_back(wstrFilename.GetString());
1506+
file2Change.push_back(wstrFilename);
15071507
//thisFolderUpdater->updateTree(dwAction, file2Change);
15081508
::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RNFILE, reinterpret_cast<WPARAM>(nullptr), reinterpret_cast<LPARAM>(&file2Change));
15091509
}

PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "ReadDirectoryChanges.h"
3030
#include "ReadDirectoryChangesPrivate.h"
31+
#include <process.h>
3132

3233
using namespace ReadDirectoryChangesPrivate;
3334

@@ -85,13 +86,13 @@ void CReadDirectoryChanges::AddDirectory( LPCTSTR szDirectory, BOOL bWatchSubtre
8586
QueueUserAPC(CReadChangesServer::AddDirectoryProc, m_hThread, (ULONG_PTR)pRequest);
8687
}
8788

88-
void CReadDirectoryChanges::Push(DWORD dwAction, CStringW& wstrFilename)
89+
void CReadDirectoryChanges::Push(DWORD dwAction, generic_string& wstrFilename)
8990
{
9091
TDirectoryChangeNotification dirChangeNotif = TDirectoryChangeNotification(dwAction, wstrFilename);
9192
m_Notifications.push(dirChangeNotif);
9293
}
9394

94-
bool CReadDirectoryChanges::Pop(DWORD& dwAction, CStringW& wstrFilename)
95+
bool CReadDirectoryChanges::Pop(DWORD& dwAction, generic_string& wstrFilename)
9596
{
9697
TDirectoryChangeNotification pair;
9798
if (!m_Notifications.pop(pair))

PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141

4242
#include <windows.h>
4343

44-
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
45-
46-
#include <atlbase.h>
47-
#include <atlstr.h>
44+
#include "Common.h" //for generic_string
4845

4946
#include <vector>
5047
#include <list>
@@ -53,7 +50,7 @@ using namespace std;
5350

5451
#include "ThreadSafeQueue.h"
5552

56-
typedef pair<DWORD,CStringW> TDirectoryChangeNotification;
53+
typedef pair<DWORD, generic_string> TDirectoryChangeNotification;
5754

5855
namespace ReadDirectoryChangesPrivate
5956
{
@@ -143,10 +140,10 @@ class CReadDirectoryChanges
143140
/// </summary>
144141
HANDLE GetWaitHandle() { return m_Notifications.GetWaitHandle(); }
145142

146-
bool Pop(DWORD& dwAction, CStringW& wstrFilename);
143+
bool Pop(DWORD& dwAction, generic_string& wstrFilename);
147144

148145
// "Push" is for usage by ReadChangesRequest. Not intended for external usage.
149-
void Push(DWORD dwAction, CStringW& wstrFilename);
146+
void Push(DWORD dwAction, generic_string& wstrFilename);
150147

151148
// Check if the queue overflowed. If so, clear it and return true.
152149
bool CheckOverflow();

PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "ReadDirectoryChanges.h"
3030
#include "ReadDirectoryChangesPrivate.h"
31+
#include "Shlwapi.h"
3132

3233

3334
// The namespace is a convenience to emphasize that these are internals
@@ -71,7 +72,7 @@ bool CReadChangesRequest::OpenDirectory()
7172
return true;
7273

7374
m_hDirectory = ::CreateFileW(
74-
m_wstrDirectory, // pointer to the file name
75+
m_wstrDirectory.c_str(), // pointer to the file name
7576
FILE_LIST_DIRECTORY, // access (read/write) mode
7677
FILE_SHARE_READ // share mode
7778
| FILE_SHARE_WRITE
@@ -147,23 +148,23 @@ void CReadChangesRequest::ProcessNotification()
147148
{
148149
FILE_NOTIFY_INFORMATION& fni = (FILE_NOTIFY_INFORMATION&)*pBase;
149150

150-
CStringW wstrFilename(fni.FileName, fni.FileNameLength/sizeof(wchar_t));
151+
generic_string wstrFilename(fni.FileName, fni.FileNameLength/sizeof(wchar_t));
151152
// Handle a trailing backslash, such as for a root directory.
152-
if (wstrFilename.Right(1) != L"\\")
153+
if (!wstrFilename.empty() && wstrFilename.back() != L'\\')
153154
wstrFilename = m_wstrDirectory + L"\\" + wstrFilename;
154155
else
155156
wstrFilename = m_wstrDirectory + wstrFilename;
156157

157158
// If it could be a short filename, expand it.
158-
LPCWSTR wszFilename = PathFindFileNameW(wstrFilename);
159+
LPCWSTR wszFilename = PathFindFileNameW(wstrFilename.c_str());
159160
int len = lstrlenW(wszFilename);
160161
// The maximum length of an 8.3 filename is twelve, including the dot.
161162
if (len <= 12 && wcschr(wszFilename, L'~'))
162163
{
163164
// Convert to the long filename form. Unfortunately, this
164165
// does not work for deletions, so it's an imperfect fix.
165166
wchar_t wbuf[MAX_PATH];
166-
if (::GetLongPathNameW(wstrFilename, wbuf, _countof(wbuf)) > 0)
167+
if (::GetLongPathNameW(wstrFilename.c_str(), wbuf, _countof(wbuf)) > 0)
167168
wstrFilename = wbuf;
168169
}
169170

PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CReadChangesRequest
7777
// Parameters from the caller for ReadDirectoryChangesW().
7878
DWORD m_dwFilterFlags;
7979
BOOL m_bIncludeChildren;
80-
CStringW m_wstrDirectory;
80+
generic_string m_wstrDirectory;
8181

8282
// Result of calling CreateFile().
8383
HANDLE m_hDirectory;

PowerEditor/src/WinControls/ReadDirectoryChanges/ThreadSafeQueue.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
// See ReadMe.txt for overview information.
2828

2929
#include <list>
30+
#include <mutex>
3031

3132
template <typename C>
3233
class CThreadSafeQueue : protected std::list<C>
@@ -51,14 +52,14 @@ class CThreadSafeQueue : protected std::list<C>
5152

5253
void push(C& c)
5354
{
54-
CComCritSecLock<CComAutoCriticalSection> lock( m_Crit, true );
55+
std::unique_lock<std::mutex> lock(mtx);
5556
push_back( c );
56-
lock.Unlock();
57+
lock.unlock();
5758

5859
if (!::ReleaseSemaphore(m_hSemaphore, 1, NULL))
5960
{
6061
// If the semaphore is full, then take back the entry.
61-
lock.Lock();
62+
lock.lock();
6263
pop_back();
6364
if (GetLastError() == ERROR_TOO_MANY_POSTS)
6465
{
@@ -69,7 +70,7 @@ class CThreadSafeQueue : protected std::list<C>
6970

7071
bool pop(C& c)
7172
{
72-
CComCritSecLock<CComAutoCriticalSection> lock( m_Crit, true );
73+
std::unique_lock<std::mutex> lock(mtx);
7374

7475
// If the user calls pop() more than once after the
7576
// semaphore is signaled, then the semaphore count will
@@ -90,7 +91,7 @@ class CThreadSafeQueue : protected std::list<C>
9091
// If overflow, use this to clear the queue.
9192
void clear()
9293
{
93-
CComCritSecLock<CComAutoCriticalSection> lock( m_Crit, true );
94+
std::unique_lock<std::mutex> lock(mtx);
9495

9596
for (DWORD i=0; i<size(); i++)
9697
WaitForSingleObject(m_hSemaphore, 0);
@@ -110,7 +111,7 @@ class CThreadSafeQueue : protected std::list<C>
110111
protected:
111112
HANDLE m_hSemaphore;
112113

113-
CComAutoCriticalSection m_Crit;
114+
std::mutex mtx;
114115

115116
bool m_bOverflow;
116117
};

0 commit comments

Comments
 (0)