summaryrefslogtreecommitdiff
path: root/lib/Thumbnail
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Thumbnail')
-rw-r--r--lib/Thumbnail/Thumbnail.vcxproj10
-rw-r--r--lib/Thumbnail/thumbnail.cpp35
2 files changed, 22 insertions, 23 deletions
diff --git a/lib/Thumbnail/Thumbnail.vcxproj b/lib/Thumbnail/Thumbnail.vcxproj
index 2045f10e..87fb152b 100644
--- a/lib/Thumbnail/Thumbnail.vcxproj
+++ b/lib/Thumbnail/Thumbnail.vcxproj
@@ -66,10 +66,8 @@
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
@@ -87,7 +85,7 @@
</BuildLog>
<ClCompile>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>FFS_WIN;FFS_WIN;_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;ZEN_WIN;_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -122,7 +120,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>FFS_WIN;_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -155,7 +153,7 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>FFS_WIN;FFS_WIN;NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
@@ -192,7 +190,7 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>FFS_WIN;NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>ZEN_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
diff --git a/lib/Thumbnail/thumbnail.cpp b/lib/Thumbnail/thumbnail.cpp
index b00ce81d..53c30bc3 100644
--- a/lib/Thumbnail/thumbnail.cpp
+++ b/lib/Thumbnail/thumbnail.cpp
@@ -11,6 +11,7 @@
#define WIN32_LEAN_AND_MEAN
#include <zen/win.h>
#include <zen/win_ver.h>
+#include <zen/sys_error.h>
#define STRICT_TYPED_ITEMIDS //better type safety for IDLists
#include <Shlobj.h>
@@ -30,9 +31,9 @@ using namespace zen;
namespace
{
-thumb::ImageData* allocImageData(int width, int height) //throw ComError; return value always bound!
+thumb::ImageData* allocImageData(int width, int height) //throw SysError; return value always bound!
{
- ZEN_COM_ASSERT(width >= 0 && height >= 0); //throw ComError
+ ZEN_COM_ASSERT(width >= 0 && height >= 0); //throw SysError
std::unique_ptr<thumb::ImageData> idata = make_unique<thumb::ImageData>();
@@ -55,7 +56,7 @@ void releaseImageData_impl(const thumb::ImageData* id)
//caller takes ownership!
-HICON createIconFromBitmap(HBITMAP bitmap) //throw ComError
+HICON createIconFromBitmap(HBITMAP bitmap) //throw SysError
{
BITMAP bmpInfo = {};
ZEN_COM_ASSERT(::GetObject(bitmap, //__in HGDIOBJ hgdiobj,
@@ -77,13 +78,13 @@ HICON createIconFromBitmap(HBITMAP bitmap) //throw ComError
iconInfo.hbmMask = bitmapMask;
HICON result = ::CreateIconIndirect(&iconInfo);
- if (!result) throw ComError(L"Error calling \"CreateIconIndirect\".", GetLastError());
+ if (!result) throw SysError(formatSystemError(L"CreateIconIndirect", getLastError()));
return result;
}
//caller takes ownership!
-thumb::ImageData* convertToImageData(HBITMAP bmp) //throw ComError
+thumb::ImageData* convertToImageData(HBITMAP bmp) //throw SysError
{
//GetDIBits ????
@@ -145,13 +146,13 @@ thumb::ImageData* convertToImageData(HBITMAP bmp) //throw ComError
0, //_In_ int nXSrc,
0, //_In_ int nYSrc,
SRCCOPY)) //_In_ DWORD dwRop
- throw ComError(L"Error calling \"BitBlt\".", GetLastError());
+ throw SysError(formatSystemError(L"BitBlt", getLastError()));
//CreateDIBSection: "Access to the bitmap must be synchronized. [...]. This applies to any use of the pointer to the bitmap bit values."
/*bool rv = */
::GdiFlush();
- thumb::ImageData* imgOut = allocImageData(bmpInfo.bmWidth, bmpInfo.bmHeight); //throw ComError
+ thumb::ImageData* imgOut = allocImageData(bmpInfo.bmWidth, bmpInfo.bmHeight); //throw SysError
ScopeGuard guardImgData = zen::makeGuard([&] { releaseImageData_impl(imgOut); });
unsigned char* rgbPtr = imgOut->rgb;
@@ -176,13 +177,13 @@ thumb::ImageData* convertToImageData(HBITMAP bmp) //throw ComError
//caller takes ownership!
-const thumb::ImageData* getThumbnail_impl(const wchar_t* filename, int requestedSize) //throw ComError
+const thumb::ImageData* getThumbnail_impl(const wchar_t* filename, int requestedSize) //throw SysError
{
const std::wstring filenameStr(filename);
ComPtr<IShellFolder> desktopFolder;
- ZEN_COM_CHECK(::SHGetDesktopFolder(desktopFolder.init())); //throw ComError
- ZEN_COM_ASSERT(desktopFolder); //throw ComError -> better safe than sorry?
+ ZEN_COM_CHECK(::SHGetDesktopFolder(desktopFolder.init())); //throw SysError
+ ZEN_COM_ASSERT(desktopFolder); //throw SysError -> better safe than sorry?
PIDLIST_RELATIVE pidlFolder = nullptr;
{
@@ -246,14 +247,14 @@ const thumb::ImageData* getThumbnail_impl(const wchar_t* filename, int requested
ZEN_COM_ASSERT(bitmap);
ZEN_ON_SCOPE_EXIT(::DeleteObject(bitmap));
- return convertToImageData(bitmap); //throw ComError, pass ownership
+ return convertToImageData(bitmap); //throw SysError, pass ownership
}
const bool wereVistaOrLater = vistaOrLater(); //thread-safety: init at startup
//caller takes ownership!
-const thumb::ImageData* getIconByIndex_impl(int iconIndex, thumb::IconSizeType st) //throw ComError
+const thumb::ImageData* getIconByIndex_impl(int iconIndex, thumb::IconSizeType st) //throw SysError
{
//Note:
//- using IExtractIcon::Extract is *no* alternative, just as ::SHGetFileInfo(), it only supports small (16x16) and large (32x32) icons
@@ -413,7 +414,7 @@ const thumb::ImageData* getIconByIndex_impl(int iconIndex, thumb::IconSizeType s
/*bool rv = */
::GdiFlush();
- ImageData* imgOut = allocImageData(targetWidth, targetHeight); //throw ComError
+ ImageData* imgOut = allocImageData(targetWidth, targetHeight); //throw SysError
ScopeGuard guardImgData = zen::makeGuard([&] { releaseImageData_impl(imgOut); });
unsigned char* rgbPtr = imgOut->rgb;
@@ -457,9 +458,9 @@ const thumb::ImageData* thumb::getThumbnail(const wchar_t* filename, int request
{
try
{
- return getThumbnail_impl(filename, requestedSize); //throw ComError
+ return getThumbnail_impl(filename, requestedSize); //throw SysError
}
- catch (const ComError&)
+ catch (const SysError&)
{
return nullptr;
}
@@ -470,9 +471,9 @@ const thumb::ImageData* thumb::getIconByIndex(int iconIndex, thumb::IconSizeType
{
try
{
- return getIconByIndex_impl(iconIndex, st); //throw ComError
+ return getIconByIndex_impl(iconIndex, st); //throw SysError
}
- catch (const ComError&)
+ catch (const SysError&)
{
return nullptr;
}
bgstack15