From 598cb9cce233600f00ab457cf12a241e13362647 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Jul 2012 19:23:37 +0000 Subject: fix for a random crash in TTB git-svn-id: http://svn.miranda-ng.org/main/trunk@725 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TopToolBar/toolbar.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'plugins/TopToolBar') diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index 510a3a8989..8a39e73a09 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -46,12 +46,15 @@ int SetAllBitmaps() return 0; } -TopButtonInt* idtopos(int id) +static TopButtonInt* idtopos(int id, int* pPos=NULL) { for ( int i = 0; i < Buttons.getCount(); i++) - if (Buttons[i]->id == id) + if (Buttons[i]->id == id) { + if (pPos) *pPos = i; return Buttons[i]; + } + if (pPos) *pPos = -1; return NULL; } @@ -177,7 +180,8 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam) { lockbut(); - TopButtonInt* b = idtopos(wParam); + int idx; + TopButtonInt* b = idtopos(wParam, &idx); if (b == NULL) { ulockbut(); return -1; @@ -185,14 +189,11 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam) RemoveFromOptions(b->id); - int idx = Buttons.getIndex(b); - if (idx != -1) - Buttons.remove(idx); + Buttons.remove(idx); delete b; ArrangeButtons(); ulockbut(); -// OptionsPageRebuild(); return 0; } -- cgit v1.2.3