From d9c995acca09460e8b8533c7efdb5eddd6e61d73 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 23 May 2013 14:50:43 +0000 Subject: fix for invalid account ordering in Options -> Contact List -> Accounts git-svn-id: http://svn.miranda-ng.org/main/trunk@4810 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/protocolorder.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/modules') diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp index 23b88d57e8..953833970c 100644 --- a/src/modules/clist/protocolorder.cpp +++ b/src/modules/clist/protocolorder.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef struct tagProtocolData { char *RealName; - int protopos; int show, enabled; } ProtocolData; @@ -104,7 +103,16 @@ bool CheckProtocolOrder(void) return changed; } -int FillTree(HWND hwnd) +static bool ProtoToInclude(PROTOACCOUNT *pa) +{ + if ( !Proto_IsAccountEnabled(pa)) + return false; + + PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName); + return (pd != NULL && pd->type == PROTOTYPE_PROTOCOL); +} + +static int FillTree(HWND hwnd) { TVINSERTSTRUCT tvis; tvis.hParent = NULL; @@ -121,16 +129,11 @@ int FillTree(HWND hwnd) continue; PROTOACCOUNT *pa = accounts[idx]; - if ( !Proto_IsAccountEnabled(pa)) - continue; - - PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName); - if (pd == NULL || pd->type != PROTOTYPE_PROTOCOL) + if ( !ProtoToInclude(pa)) continue; ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData)); PD->RealName = pa->szModuleName; - PD->protopos = pa->iOrder; PD->enabled = Proto_IsAccountEnabled(pa) && isProtoSuitable(pa->ppro); PD->show = PD->enabled ? pa->bIsVisible : 100; @@ -180,7 +183,7 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM switch(((LPNMHDR)lParam)->idFrom) { case 0: if (((LPNMHDR)lParam)->code == PSN_APPLY) { - int count = 0; + int idx = 0; TVITEM tvi; tvi.hItem = TreeView_GetRoot(hwndProtoOrder); @@ -194,7 +197,8 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ProtocolData* ppd = (ProtocolData*)tvi.lParam; PROTOACCOUNT* pa = Proto_GetAccount(ppd->RealName); if (pa != NULL) { - pa->iOrder = count++; + while (idx < accounts.getCount() && !ProtoToInclude(accounts[idx])) idx++; + pa->iOrder = idx++; if (ppd->enabled) pa->bIsVisible = ppd->show; } -- cgit v1.2.3