From 695540757785bb95fd20c68fc784dec8daba146c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 12 Jul 2012 20:27:14 +0000 Subject: fix for toolbar window freezing git-svn-id: http://svn.miranda-ng.org/main/trunk@933 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TopToolBar/toolbar.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index 976774acd9..cdb4b04883 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -220,12 +220,16 @@ int ArrangeButtons() int nLineCount = 0; int i, ypos = 1, xpos = g_ctrl->nButtonSpace, nextX = 0, y = 0; - int newheight = g_ctrl->nButtonHeight+1; + int newheight = g_ctrl->nButtonHeight+1, nButtonCount=0; - if (Buttons.getCount() == 0) + for (i=0; i < Buttons.getCount(); i++) + if (Buttons[i]->hwnd) + nButtonCount++; + + if (nButtonCount == 0) return 0; - HDWP hdwp = BeginDeferWindowPos(Buttons.getCount()); + HDWP hdwp = BeginDeferWindowPos(nButtonCount); bool bWasButttonBefore; int nUsedWidth, iFirstButtonId = 0, iLastButtonId = 0; @@ -238,6 +242,8 @@ int ArrangeButtons() for (i=iFirstButtonId; i < Buttons.getCount(); i++) { TopButtonInt *b = Buttons[i]; + if (b->hwnd == NULL) + continue; int width = 0; if ( b->isVisible()) @@ -254,6 +260,8 @@ int ArrangeButtons() for (i=iFirstButtonId; i < iLastButtonId; i++) { TopButtonInt *b = Buttons[i]; + if (b->hwnd == NULL) + continue; bool bOldVisible = IsWindowVisible(b->hwnd) != 0; if (bOldVisible != b->isVisible()) @@ -307,8 +315,10 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam) b->hLangpack = (int)lParam; b->LoadSettings(); b->CreateWnd(); - if (b->hwnd == NULL) + if (b->hwnd == NULL) { + delete b; return -1; + } { mir_cslock lck(csButtonsHook); Buttons.insert(b); -- cgit v1.2.3