From 38e179fe0f2e0f4335722f50b582c04a92ceb639 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Apr 2018 14:01:43 +0300 Subject: fixes #1240 (Changing account order makes some accounts disappear) - ancient evil destroyed --- src/mir_app/src/proto_order.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index 020f5e9d4c..76797e6d73 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -165,8 +165,13 @@ public: virtual void OnApply() override { + // assume all accounts are disabled + for (auto &it : accounts) + it->iOrder = -1; + int idx = 0; + // scan chosen accounts and apply the order TVITEMEX tvi; tvi.hItem = m_order.GetRoot(); tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE; @@ -177,8 +182,6 @@ public: ProtocolData *ppd = (ProtocolData*)tvi.lParam; PROTOACCOUNT *pa = Proto_GetAccount(ppd->RealName); if (pa != nullptr) { - while (idx < accounts.getCount() && !ProtoToInclude(accounts[idx])) - idx++; pa->iOrder = idx++; if (ppd->enabled) pa->bIsVisible = tvi.iImage != 0; @@ -188,6 +191,11 @@ public: tvi.hItem = m_order.GetNextSibling(tvi.hItem); } + // all accounts in the rest are disabled, so order doesn't matter + for (auto &it : accounts) + if (it->iOrder == -1) + it->iOrder = idx++; + WriteDbAccounts(); cli.pfnReloadProtoMenus(); cli.pfnTrayIconIconsChanged(); -- cgit v1.2.3