diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-02 19:23:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-02 19:23:37 +0000 |
commit | 598cb9cce233600f00ab457cf12a241e13362647 (patch) | |
tree | d2dfd732a171f88a41f3d73218e12892dbb47280 /plugins | |
parent | 2bdd151424c835908851394f99f8a57e325dfd06 (diff) |
fix for a random crash in TTB
git-svn-id: http://svn.miranda-ng.org/main/trunk@725 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/TopToolBar/toolbar.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
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;
}
|