From 43d8ad9bdc1dcd17753ce3537544feb157bf3888 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 26 Jul 2015 20:00:27 +0000 Subject: MirLua: there is no reason to store whole TTBButton struct git-svn-id: http://svn.miranda-ng.org/main/trunk@14731 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_toptoolbar.cpp | 45 +++++++++---------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) (limited to 'plugins') diff --git a/plugins/MirLua/src/m_toptoolbar.cpp b/plugins/MirLua/src/m_toptoolbar.cpp index fcc5208bef..be1739bfcc 100644 --- a/plugins/MirLua/src/m_toptoolbar.cpp +++ b/plugins/MirLua/src/m_toptoolbar.cpp @@ -1,26 +1,14 @@ #include "stdafx.h" -struct HandleTBBParam -{ - HANDLE h; - TTBButton* tbb; - HandleTBBParam(HANDLE h, TTBButton* tbb) : h(h), tbb(tbb) { } -}; - -static LIST TBButtons(1, HandleKeySortT); +static LIST TBButtons(1, PtrKeySortT); void KillModuleTTBButton() { while (TBButtons.getCount()) { - HandleTBBParam* param = (HandleTBBParam*)TBButtons[0]; - ::CallService(MS_TTB_REMOVEBUTTON, (WPARAM)param->h, 0); + HANDLE hTTButton = TBButtons[0]; + ::CallService(MS_TTB_REMOVEBUTTON, (WPARAM)hTTButton, 0); TBButtons.remove(0); - mir_free(param->tbb->name); - mir_free(param->tbb->pszTooltipUp); - mir_free(param->tbb->pszTooltipDn); - mir_free(param->tbb); - delete param; } } @@ -106,14 +94,12 @@ static int lua_AddButton(lua_State *L) lua_pushlightuserdata(L, res); if (res != INVALID_HANDLE_VALUE) - TBButtons.insert(new HandleTBBParam(res, tbb)); - else - { - mir_free(tbb->name); - mir_free(tbb->pszTooltipUp); - mir_free(tbb->pszTooltipDn); - mir_free(tbb); - } + TBButtons.insert(res); + + mir_free(tbb->name); + mir_free(tbb->pszTooltipUp); + mir_free(tbb->pszTooltipDn); + mir_free(tbb); return 1; } @@ -126,18 +112,7 @@ static int lua_RemoveButton(lua_State *L) lua_pushinteger(L, res); if (!res) - { - HandleTBBParam* param = (HandleTBBParam*)TBButtons.find(&hTTButton); - if (param) - { - TBButtons.remove(param); - mir_free(param->tbb->name); - mir_free(param->tbb->pszTooltipUp); - mir_free(param->tbb->pszTooltipDn); - mir_free(param->tbb); - delete param; - } - } + TBButtons.remove(hTTButton); return 1; } -- cgit v1.2.3