summaryrefslogtreecommitdiff
path: root/lib/Thumbnail/thumbnail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Thumbnail/thumbnail.cpp')
-rw-r--r--lib/Thumbnail/thumbnail.cpp35
1 files changed, 18 insertions, 17 deletions
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