From 210acddc8bc8d48c7a3d71c09db0eed3f5a9c2b0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 10 Jun 2020 22:02:52 +0300 Subject: =?UTF-8?q?fixes=20#2438=20(Jabber:=20=D1=81=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=D0=B2=D0=B0=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=20=D1=81=D0=B5=D0=B1=D1=8F=20=D0=B2=D0=B5=D0=B4=D1=83=D1=82)?= =?UTF-8?q?=20+=20some=20another=20DoModal()=20calls=20cleaning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/JabberG/src/jabber_privacy.cpp | 52 +++++++++++++++----------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 5c9cfb9eff..9a415c336c 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -1666,8 +1666,7 @@ public: CPrivacyList *pList = GetSelectedList(m_hwnd); if (pList && pRule) { CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule); - int nResult = dlgPrivacyRule.DoModal(); - if (nResult) { + if (dlgPrivacyRule.DoModal()) { pList->SetModified(); ::PostMessage(m_hwnd, WM_PROTO_REFRESH, 0, 0); } @@ -1683,8 +1682,7 @@ public: if (pList) { CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, "", FALSE); CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule); - int nResult = dlgPrivacyRule.DoModal(); - if (nResult) { + if (dlgPrivacyRule.DoModal()) { pList->AddRule(pRule); pList->Reorder(); pList->SetModified(); @@ -1752,35 +1750,36 @@ public: // FIXME: line length is hard coded in dialog procedure CJabberDlgPrivacyAddList dlgPrivacyAddList(m_proto, m_hwnd); int nRetVal = dlgPrivacyAddList.DoModal(); - if (nRetVal && mir_strlen(dlgPrivacyAddList.szLine)) { - mir_cslockfull lck(m_proto->m_privacyListManager.m_cs); - - CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine); - if (pList == nullptr) { - m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine); - pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine); - if (pList) { - pList->SetModified(TRUE); - pList->SetLoaded(TRUE); - } - } - if (pList) - pList->SetDeleted(FALSE); - int nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)dlgPrivacyAddList.szLine); - if (nSelected == CB_ERR) { - nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)dlgPrivacyAddList.szLine); - SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList); - SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0); + if (!nRetVal || !mir_strlen(dlgPrivacyAddList.szLine)) + return; + + mir_cslock lck(m_proto->m_privacyListManager.m_cs); + + CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine); + if (pList == nullptr) { + m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine); + pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine); + if (pList) { + pList->SetModified(TRUE); + pList->SetLoaded(TRUE); } + } + if (pList) + pList->SetDeleted(FALSE); - lck.unlock(); - PostMessage(m_hwnd, WM_PROTO_REFRESH, 0, 0); + int nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)dlgPrivacyAddList.szLine); + if (nSelected == CB_ERR) { + nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)dlgPrivacyAddList.szLine); + SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList); + SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0); } + + PostMessage(m_hwnd, WM_PROTO_REFRESH, 0, 0); } void btnRemoveList_OnClick(CCtrlButton*) { - mir_cslockfull lck(m_proto->m_privacyListManager.m_cs); + mir_cslock lck(m_proto->m_privacyListManager.m_cs); CPrivacyList *pList = GetSelectedList(m_hwnd); if (pList) { @@ -1795,7 +1794,6 @@ public: pList->SetModified(); } - lck.unlock(); PostMessage(m_hwnd, WM_PROTO_REFRESH, 0, 0); } -- cgit v1.2.3