From 79a54d68edb91e6e544f0ab6aae17917ada307e0 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 7 Jan 2021 13:40:01 +0100 Subject: [PATCH 1/2] Revert "Fix CfAPI wrapper build in Win32 mode" This reverts commit 3b3864296a2bc09540989241325e938ed5a3275e. --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 5fba7b724..62ffcffa1 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -346,13 +346,13 @@ OCC::CfApiWrapper::FileHandle OCC::CfApiWrapper::handleForPath(const QString &pa HANDLE handle = nullptr; const qint64 openResult = CfOpenFileWithOplock(path.toStdWString().data(), CF_OPEN_FILE_FLAG_NONE, &handle); if (openResult == S_OK) { - return FileHandle(handle, CfCloseHandle); + return {handle, CfCloseHandle}; } } else { const auto handle = CreateFile(path.toStdWString().data(), 0, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle != INVALID_HANDLE_VALUE) { - return FileHandle(handle, [](HANDLE h) { CloseHandle(h); }); + return {handle, [](HANDLE h) { CloseHandle(h); }}; } } From 2d8eb19ee5a9c4cc78b7d70a19855483466217db Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 7 Jan 2021 13:41:51 +0100 Subject: [PATCH 2/2] Second attempt at fixing CfAPI wrapper build in Win32 mode MSVC having so useless error messages it didn't quite point to the root cause of the issue... it turns out that through the maze of macros defined in the windows API, there's one which impacted the function pointer definition of CfCloseHandle which would then not convert to FileHandle::Deleter as expected. So I end up wrapping it in a lambda to help... luckily this kind of lambdas decay into a simple function pointer so there's likely no overhead it's just to coerce the compiler into doing the right thing. Signed-off-by: Kevin Ottens --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 62ffcffa1..1b40222ab 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -346,7 +346,7 @@ OCC::CfApiWrapper::FileHandle OCC::CfApiWrapper::handleForPath(const QString &pa HANDLE handle = nullptr; const qint64 openResult = CfOpenFileWithOplock(path.toStdWString().data(), CF_OPEN_FILE_FLAG_NONE, &handle); if (openResult == S_OK) { - return {handle, CfCloseHandle}; + return {handle, [](HANDLE h) { CfCloseHandle(h); }}; } } else { const auto handle = CreateFile(path.toStdWString().data(), 0, 0, nullptr,