diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-02 14:01:43 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-02 14:01:43 +0300 |
commit | 38e179fe0f2e0f4335722f50b582c04a92ceb639 (patch) | |
tree | 20275a89b4dc93ea7fe2dcc5cc4faca04020f138 | |
parent | f415d65108ca2e4af803e44dddb94cecbaf6dc15 (diff) |
fixes #1240 (Changing account order makes some accounts disappear) - ancient evil destroyed
-rw-r--r-- | src/mir_app/src/proto_order.cpp | 12 |
1 files 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();
|