Windows: build with UNICODE, get rid of all TCHAR/TEXT(), use explicit
xxA() interfaces and wchar_t in some places. Add a static cleanup retry method to TempFile, called after clearing the MimeHandler cache (killing the subprocesses which might hold an open file).
This commit is contained in:
+10
-10
@@ -108,6 +108,13 @@ static string argvToCmdLine(const string& cmd, const vector<string>& args)
|
||||
return cmdline;
|
||||
}
|
||||
|
||||
// Because we build with UNICODE defined, GetEnvironmentStrings is
|
||||
// defined as GetEnvironmentStringsW. Because of a Windows problem teh
|
||||
// GetEnvironmentStrings function is really a GetEnvironmentStringsA,
|
||||
// which is what we want.
|
||||
// See: https://devblogs.microsoft.com/oldnewthing/20130117-00/?p=5533
|
||||
#undef GetEnvironmentStrings
|
||||
|
||||
// Merge the father environment with the variable specified in m_env
|
||||
static char *mergeEnvironment(const std::unordered_map<string, string>& addenv)
|
||||
{
|
||||
@@ -131,7 +138,7 @@ static char *mergeEnvironment(const std::unordered_map<string, string>& addenv)
|
||||
}
|
||||
}
|
||||
|
||||
FreeEnvironmentStrings(envir);
|
||||
FreeEnvironmentStringsA(envir);
|
||||
|
||||
// Merge our values
|
||||
for (auto it = addenv.begin(); it != addenv.end(); it++) {
|
||||
@@ -614,7 +621,7 @@ bool ExecCmd::Internal::preparePipes(bool has_input,HANDLE *hChildInput,
|
||||
// attribute, and the options are important.
|
||||
// use CreateFile to open a new handle to the existing pipe...
|
||||
sa.bInheritHandle = TRUE;
|
||||
hOutputWrite = CreateFile(
|
||||
hOutputWrite = CreateFileA(
|
||||
pipeName.c_str(),
|
||||
FILE_WRITE_DATA | SYNCHRONIZE,
|
||||
0, &sa, OPEN_EXISTING, // very important flag!
|
||||
@@ -659,7 +666,7 @@ bool ExecCmd::Internal::preparePipes(bool has_input,HANDLE *hChildInput,
|
||||
}
|
||||
|
||||
sa.bInheritHandle = TRUE;
|
||||
hInputRead = CreateFile(
|
||||
hInputRead = CreateFileA(
|
||||
pipeName.c_str(),
|
||||
FILE_READ_DATA | SYNCHRONIZE,
|
||||
0, &sa, OPEN_EXISTING, // very important flag!
|
||||
@@ -782,13 +789,7 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
|
||||
char *envir = mergeEnvironment(m->m_env);
|
||||
|
||||
// Create the child process.
|
||||
// Need a writable buffer for the command line, for some reason.
|
||||
LOGDEB("ExecCmd:startExec: cmdline [" << cmdline << "]\n");
|
||||
#if 0
|
||||
LPSTR buf = (LPSTR)malloc(cmdline.size() + 1);
|
||||
memcpy(buf, cmdline.c_str(), cmdline.size());
|
||||
buf[cmdline.size()] = 0;
|
||||
#endif
|
||||
SYSPATH(cmdline, wcmdline);
|
||||
bSuccess = CreateProcessW(NULL,
|
||||
wcmdline, // command line
|
||||
@@ -805,7 +806,6 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
|
||||
}
|
||||
|
||||
free(envir);
|
||||
// free(buf);
|
||||
// Close child-side handles else we'll never see eofs
|
||||
if (!CloseHandle(hOutputWrite))
|
||||
printError("CloseHandle");
|
||||
|
||||
@@ -10,9 +10,7 @@ TARGET = librecoll
|
||||
TEMPLATE = lib
|
||||
|
||||
DEFINES += LIBRECOLL_LIBRARY BUILDING_RECOLL
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
DEFINES += _MBCS
|
||||
DEFINES += UNICODE
|
||||
DEFINES += PSAPI_VERSION=1
|
||||
DEFINES += READFILE_ENABLE_MINIZ
|
||||
DEFINES += READFILE_ENABLE_MD5
|
||||
|
||||
@@ -5,9 +5,7 @@ TARGET = rclstartw
|
||||
TEMPLATE = app
|
||||
|
||||
DEFINES += BUILDING_RECOLL
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
DEFINES += _MBCS
|
||||
DEFINES += UNICODE
|
||||
DEFINES += PSAPI_VERSION=1
|
||||
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
|
||||
DEFINES += BUILDING_RECOLL
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
DEFINES += _MBCS
|
||||
DEFINES += UNICODE
|
||||
DEFINES += PSAPI_VERSION=1
|
||||
DEFINES += RCL_MONITOR
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
|
||||
DEFINES += BUILDING_RECOLL
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
DEFINES += _MBCS
|
||||
DEFINES += UNICODE
|
||||
DEFINES += PSAPI_VERSION=1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user