From 810944bb10a541b1e047555b9bd965dccfccd5b1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 9 Apr 2018 22:00:39 +0300 Subject: fixes #1256 completely --- plugins/Import/src/import.cpp | 4 +++- plugins/Import/src/wizard.cpp | 1 + src/mir_app/src/proto_opts.cpp | 23 ++++++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 9f854ced14..527e922cfb 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -485,12 +485,15 @@ bool ImportAccounts(OBJLIST &arSkippedModules) if (!Proto_GetAccount(p->szSrcAcc)) szNewInternalName = p->szSrcAcc; // but if the original internal name is available, keep it + CopySettings(NULL, p->szSrcAcc, NULL, szNewInternalName); + p->pa = Proto_CreateAccount(szNewInternalName, p->szBaseProto, p->tszSrcName); if (p->pa == nullptr) { AddMessage(LPGENW("Unable to create an account %s of protocol %S"), p->tszSrcName, p->szBaseProto); continue; } } + else CopySettings(NULL, p->szSrcAcc, NULL, p->pa->szModuleName); char szSetting[100]; itoa(400 + p->iSrcIndex, szSetting, 10); @@ -511,7 +514,6 @@ bool ImportAccounts(OBJLIST &arSkippedModules) db_set_ws(NULL, "Protocols", szSetting, p->pa->tszAccountName); } - CopySettings(NULL, p->szSrcAcc, NULL, p->pa->szModuleName); if (bImportSysAll) arSkippedModules.insert(newStr(p->szSrcAcc)); } diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp index 4f54560ddc..459b0f4391 100644 --- a/plugins/Import/src/wizard.cpp +++ b/plugins/Import/src/wizard.cpp @@ -165,6 +165,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP break; case WM_DESTROY: + hwndWizard = nullptr; if (g_bSendQuit) PostQuitMessage(0); } diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index 87032ad73f..15349f6595 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -82,6 +82,15 @@ MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const ch db_set_s(0, pa->szModuleName, "AM_BaseProto", pszBaseProto); accounts.insert(pa); + if (ActivateAccount(pa)) { + if (bModulesLoadedFired) + pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); + if (!db_get_b(0, "CList", "MoveProtoMenus", true)) + pa->ppro->OnEvent(EV_PROTO_ONMENU, 0, 0); + } + + WriteDbAccounts(); + NotifyEventHooks(hAccListChanged, PRAC_ADDED, (LPARAM)pa); return pa; } @@ -898,17 +907,13 @@ void CAccountFormDlg::OnOk(CCtrlButton*) rtrim(buf); m_pa = Proto_CreateAccount(buf, szBaseProto, tszAccName); - if (ActivateAccount(m_pa)) { - if (bModulesLoadedFired) - m_pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); - if (!db_get_b(0, "CList", "MoveProtoMenus", true)) - m_pa->ppro->OnEvent(EV_PROTO_ONMENU, 0, 0); - } } - else replaceStrW(m_pa->tszAccountName, tszAccName); + else { + replaceStrW(m_pa->tszAccountName, tszAccName); - WriteDbAccounts(); - NotifyEventHooks(hAccListChanged, m_action, (LPARAM)m_pa); + WriteDbAccounts(); + NotifyEventHooks(hAccListChanged, m_action, (LPARAM)m_pa); + } m_pParent->Refresh(); EndModal(IDOK); -- cgit v1.2.3