From cfdcb484e0920e7c4cbd36b413b17d83a106dac6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Mar 2013 19:57:39 +0000 Subject: fix for crash in Tipper git-svn-id: http://svn.miranda-ng.org/main/trunk@3888 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TipperYM/src/bitmap_func.cpp | 4 ++-- plugins/TipperYM/src/mir_smileys.cpp | 46 +++++++++++++----------------------- 2 files changed, 19 insertions(+), 31 deletions(-) (limited to 'plugins/TipperYM') diff --git a/plugins/TipperYM/src/bitmap_func.cpp b/plugins/TipperYM/src/bitmap_func.cpp index 52ab9a2cc9..4e747fb90a 100644 --- a/plugins/TipperYM/src/bitmap_func.cpp +++ b/plugins/TipperYM/src/bitmap_func.cpp @@ -479,8 +479,8 @@ void SaveAlpha(LPRECT lpRect) if (lpRect->left < 0) lpRect->left = 0; if (lpRect->top < 0) lpRect->top = 0; - if (lpRect->right > skin.iWidth) lpRect->right = skin.iWidth; - if (lpRect->bottom > skin.iHeight) lpRect->bottom = skin.iHeight; + if (lpRect->right - lpRect->left > skin.iWidth) lpRect->right = lpRect->left + skin.iWidth; + if (lpRect->bottom - lpRect->top > skin.iHeight) lpRect->bottom = lpRect->top + skin.iHeight; int x = lpRect->left; int y = lpRect->top; diff --git a/plugins/TipperYM/src/mir_smileys.cpp b/plugins/TipperYM/src/mir_smileys.cpp index f736bf991c..1a26a370dd 100644 --- a/plugins/TipperYM/src/mir_smileys.cpp +++ b/plugins/TipperYM/src/mir_smileys.cpp @@ -73,52 +73,40 @@ void Smileys_FreeParse(SMILEYPARSEINFO parseInfo) // parseInfo is optional (pass NULL and it will be calculated and deleted inside function int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SMILEYPARSEINFO parseInfo) { - int result; - if (nCount == -1) nCount = (int)lstrlen(lpString); - if (uFormat & DT_CALCRECT) - { + if (uFormat & DT_CALCRECT) { SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); lpRect->bottom = text_size.cy; - if (text_size.cx < lpRect->right - lpRect->left) - { + if (text_size.cx < lpRect->right - lpRect->left) { if (uFormat & DT_RIGHT) lpRect->left = lpRect->right - text_size.cx; else lpRect->right = lpRect->left + text_size.cx; } - result = text_size.cy; + return text_size.cy; } - else - { - // Draw - if (parseInfo->pieces == NULL) - { - result = DrawText(hDC, lpString, nCount, lpRect, uFormat); - } - else - { - RECT rc = *lpRect; - SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); - if (text_size.cx < rc.right - rc.left) - { - if (uFormat & DT_RIGHT) - rc.left = rc.right - text_size.cx; - else - rc.right = rc.left + text_size.cx; - } - result = text_size.cy; - DrawTextSmiley(hDC, rc, lpString, nCount, parseInfo, uFormat, parseInfo->max_height); - } + // Draw + if (parseInfo->pieces == NULL) + return DrawText(hDC, lpString, nCount, lpRect, uFormat); + + RECT rc = *lpRect; + SIZE text_size = GetTextSize(hDC, lpString, parseInfo, uFormat, parseInfo->max_height, (lpRect->right - lpRect->left)); + + if (text_size.cx < rc.right - rc.left) { + if (uFormat & DT_RIGHT) + rc.left = rc.right - text_size.cx; + else + rc.right = rc.left + text_size.cx; } - return result; + DrawTextSmiley(hDC, rc, lpString, nCount, parseInfo, uFormat, parseInfo->max_height); + return text_size.cy; } SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_smiley_height, int max_width) -- cgit v1.2.3