summaryrefslogtreecommitdiff
path: root/widget
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-02-19 12:08:17 +0100
committerMoonchild <moonchild@palemoon.org>2023-02-19 12:08:17 +0100
commit576ac835f0bb752a8acd055d7985bfee33b1325a (patch)
tree29f4e9aeac8f10888b31da1961eebe3f4f9ed385 /widget
parent013e19eed6cc7248d724304d2deb8c613408539d (diff)
downloaduxp-576ac835f0bb752a8acd055d7985bfee33b1325a.tar.gz
[widget] Properly test for and handle errors in target-surface creation
and mapping.
Diffstat (limited to 'widget')
-rw-r--r--widget/windows/TaskbarPreview.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp
index e7f449caf2..dd109e17e0 100644
--- a/widget/windows/TaskbarPreview.cpp
+++ b/widget/windows/TaskbarPreview.cpp
@@ -357,32 +357,38 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) {
}
RefPtr<gfxWindowsSurface> target = new gfxWindowsSurface(source->GetSize(),
gfx::SurfaceFormat::A8R8G8B8_UINT32);
- if (!target) {
+ if (target->CairoStatus() != CAIRO_STATUS_SUCCESS) {
return NS_ERROR_FAILURE;
}
- RefPtr<gfx::DataSourceSurface> srcSurface = source->GetDataSurface();
+ using DataSrcSurf = gfx::DataSourceSurface;
+ RefPtr<DataSrcSurf> srcSurface = source->GetDataSurface();
RefPtr<gfxImageSurface> imageSurface = target->GetAsImageSurface();
if (!srcSurface || !imageSurface) {
return NS_ERROR_FAILURE;
}
- gfx::DataSourceSurface::MappedSurface sourceMap;
- srcSurface->Map(gfx::DataSourceSurface::READ, &sourceMap);
- mozilla::gfx::CopySurfaceDataToPackedArray(sourceMap.mData,
- imageSurface->Data(),
- srcSurface->GetSize(),
- sourceMap.mStride,
- BytesPerPixel(srcSurface->GetFormat()));
- srcSurface->Unmap();
+ DataSrcSurf::ScopedMap const sourceMap(srcSurface, DataSrcSurf::READ);
+ if (sourceMap.IsMapped()) {
+ mozilla::gfx::CopySurfaceDataToPackedArray(sourceMap.GetData(),
+ imageSurface->Data(),
+ srcSurface->GetSize(),
+ sourceMap.GetStride(),
+ BytesPerPixel(srcSurface->GetFormat()));
+ } else if (source->GetSize().IsEmpty()) {
+ // A zero-size source-surface probably shouldn't happen, but is harmless
+ // here. Fall through.
+ } else {
+ return NS_ERROR_FAILURE;
+ }
HDC hDC = target->GetDC();
HBITMAP hBitmap = (HBITMAP)GetCurrentObject(hDC, OBJ_BITMAP);
DWORD flags = aDrawBorder ? DWM_SIT_DISPLAYFRAME : 0;
- POINT pptClient = { 0, 0 };
HRESULT hr;
if (!mIsThumbnail) {
+ POINT pptClient = { 0, 0 };
hr = DwmSetIconicLivePreviewBitmap(mPreview->PreviewWindow(),
hBitmap, &pptClient, flags);
} else {
@@ -390,6 +396,7 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) {
hBitmap, flags);
}
MOZ_ASSERT(SUCCEEDED(hr));
+ mozilla::Unused << hr;
return NS_OK;
}