From 88d7709f7ce9d0b86d1ec7a220f357c5a922411c Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Tue, 12 Feb 2013 18:15:08 +0000
Subject: icon leak fix for Tipper

git-svn-id: http://svn.miranda-ng.org/main/trunk@3578 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/TipperYM/src/popwin.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

(limited to 'plugins/TipperYM/src')

diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp
index ba3785c00a..808f1a7698 100644
--- a/plugins/TipperYM/src/popwin.cpp
+++ b/plugins/TipperYM/src/popwin.cpp
@@ -184,8 +184,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
 						mir_free(swzAdvTitle);
 						// get advanced status icon
 						if (pwd->bIsIconVisible[1]) {
-							pwd->extraIcons[1].hIcon = (HICON)CallProtoService(pwd->clcit.szProto, PS_GETCUSTOMSTATUSICON, 0, 0);
-							pwd->extraIcons[1].bDestroy = true;
+							pwd->extraIcons[1].hIcon = (HICON)CallProtoService(pwd->clcit.szProto, PS_GETCUSTOMSTATUSICON, 0, LR_SHARED);
+							pwd->extraIcons[1].bDestroy = false;
 						}
 					}
 
@@ -406,8 +406,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
 
 					// fingerprint icon
 					if (pwd->bIsIconVisible[5]) {
-						if (ServiceExists(MS_FP_GETCLIENTICONT)) {
-							for (i = 0; opt.exIconsOrder[i] != 5; i++);
+						for (i = 0; opt.exIconsOrder[i] != 5; i++);
+						if ( ServiceExists(MS_FP_GETCLIENTICONT)) {
 							if (!DBGetContactSettingTString(pwd->hContact, szProto, "MirVer", &dbv)) {
 								pwd->extraIcons[i].hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)dbv.ptszVal, 0);
 								pwd->extraIcons[i].bDestroy = true;
@@ -415,7 +415,6 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
 							}
 						}
 						else if (ServiceExists(MS_FP_GETCLIENTICON)) {
-							for (i = 0; opt.exIconsOrder[i] != 5; i++);
 							if (!DBGetContactSettingString(pwd->hContact, szProto, "MirVer", &dbv)) {
 								pwd->extraIcons[i].hIcon = (HICON)CallService(MS_FP_GETCLIENTICON, (WPARAM)dbv.pszVal, 0);
 								pwd->extraIcons[i].bDestroy = true;
@@ -952,9 +951,15 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
 			pwd->rows = NULL;
 
 			// destroy icons
-			for (i = 0; i < EXICONS_COUNT; i++)
+			for (i = 0; i < EXICONS_COUNT; i++) {
+				if (pwd->extraIcons[i].hIcon == NULL)
+					continue;
+
 				if (pwd->extraIcons[i].bDestroy)
 					DestroyIcon(pwd->extraIcons[i].hIcon);
+				else
+					Skin_ReleaseIcon(pwd->extraIcons[i].hIcon);
+			}
 
 			if (pwd->clcit.swzText) {
 				mir_free(pwd->clcit.swzText);
-- 
cgit v1.2.3