diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-08-21 16:19:31 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-08-21 16:21:25 +0300 |
commit | ba815705e30d190e9d6c2fdf202a0bdbf7be5ea0 (patch) | |
tree | 8ddf2d75107abbf77809e0e9b041333e3d0d958f | |
parent | dc0167c2635c8a6d925df96c250c3412fac1a8fb (diff) |
Error handling
Change-Id: I46e5463aaa5cab41cd69c13314ee98a0c73e7ba2
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 964ff9972a1a..b0575a6b0d7d 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -271,6 +271,8 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou if (!GetCharABCWidthsI(hDC, 0, nCount, aGlyphIndices.data(), aABC.data())) { SAL_WARN("vcl.gdi", "GetCharABCWidthsI failed: " << WindowsErrorString(GetLastError())); + SelectObject(hDC, hOrigFont); + DeleteDC(hDC); return false; } @@ -296,10 +298,24 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou } TEXTMETRICW aTextMetric; - GetTextMetricsW(hDC, &aTextMetric); + if (!GetTextMetricsW(hDC, &aTextMetric)) + { + SAL_WARN("vcl.gdi", "GetTextMetrics failed: " << WindowsErrorString(GetLastError())); + SelectObject(hDC, hOrigFont); + DeleteDC(hDC); + return false; + } aChunk.mnAscentPlusIntLeading = aTextMetric.tmAscent + aTextMetric.tmInternalLeading; UINT nAlign = GetTextAlign(hDC); + if (nAlign == GDI_ERROR) + { + SAL_WARN("vcl.gdi", "GetTextAlign failed: " << WindowsErrorString(GetLastError())); + SelectObject(hDC, hOrigFont); + DeleteDC(hDC); + return false; + } + OUString sAlign; switch ((TA_LEFT|TA_CENTER|TA_RIGHT) & nAlign) { @@ -339,10 +355,24 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou sAlign += "NOUPDATECP"; LOGFONTW aLogfont; - GetObjectW(rLayout.mhFont, sizeof(aLogfont), &aLogfont); + if (!GetObjectW(rLayout.mhFont, sizeof(aLogfont), &aLogfont)) + { + SAL_WARN("vcl.gdi", "GetObject failed: " << WindowsErrorString(GetLastError())); + SelectObject(hDC, hOrigFont); + DeleteDC(hDC); + return false; + } wchar_t sFaceName[200]; int nFaceNameLen = GetTextFaceW(hDC, SAL_N_ELEMENTS(sFaceName), sFaceName); + if (!nFaceNameLen) + { + SAL_WARN("vcl.gdi", "GetTextFace failed: " << WindowsErrorString(GetLastError())); + SelectObject(hDC, hOrigFont); + DeleteDC(hDC); + return false; + } + SAL_INFO("vcl.gdi.opengl", OUString(sFaceName, nFaceNameLen) << ": " << sAlign << " Escapement=" << aLogfont.lfEscapement << |