From 39baa114522839150aa321b85d8a7b36c633ad7d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 24 Mar 2018 23:22:04 +0300 Subject: fixes #1201 (Crash after disable any plugin) --- src/mir_app/src/options.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index 9280d29cd6..da88c86c8b 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -371,7 +371,7 @@ class COptionsDlg : public CDlgBase { int m_currentPage; HTREEITEM m_hCurrentPage; - LIST m_arOpd; + LIST m_arOpd, m_arDeleted; RECT m_rcDisplay; RECT m_rcTab; HFONT m_hBoldFont; @@ -692,6 +692,7 @@ public: m_timerFilter(this, FILTER_TIMEOUT_TIMER), m_timerRebuild(this, NEW_PAGE_TIMER), m_arOpd(10), + m_arDeleted(1), m_szCaption(pszCaption), m_szGroup(pszGroup), m_szPage(pszPage), @@ -1074,6 +1075,20 @@ public: void onNewPageTimer(CTimer *pTimer) { pTimer->Stop(); + + for (auto &it : m_arDeleted) { + int idx = m_arOpd.indexOf(it); + if (idx == -1) + continue; + + if (m_currentPage > idx) + m_currentPage--; + + delete it; + m_arOpd.remove(idx); + } + m_arDeleted.destroy(); + RebuildPageTree(); } @@ -1108,17 +1123,11 @@ public: void KillModule(int _hLang) { - auto T = m_arOpd.rev_iter(); - for (auto &opd : T) { + for (auto &opd : m_arOpd) { if (opd->hLangpack != _hLang) continue; - int idx = T.indexOf(&opd); - if (m_currentPage > idx) - m_currentPage--; - - delete opd; - m_arOpd.remove(idx); + m_arDeleted.insert(opd); m_timerRebuild.Start(50); } } -- cgit v1.2.3