From 78854c09f5a444d8db078333826e7a84e14e6f2c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 1 Oct 2017 00:16:30 +0300 Subject: fix for the eternal loop --- plugins/TabSRMM/src/msglog.cpp | 56 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 7c085e3bbe..938d926472 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -1125,35 +1125,37 @@ void CTabBaseDlg::ReplaceIcons(LONG startAt, int fAppend, BOOL isSent) CComPtr ole; m_log.SendMsg(EM_GETOLEINTERFACE, 0, (LPARAM)&ole); - while (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { - CHARRANGE cr; - cr.cpMin = fi.chrgText.cpMin; - cr.cpMax = fi.chrgText.cpMax + 2; - m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&cr); + if (ole != nullptr) { + while (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { + CHARRANGE cr; + cr.cpMin = fi.chrgText.cpMin; + cr.cpMax = fi.chrgText.cpMax + 2; + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&cr); - tr.chrg.cpMin = fi.chrgText.cpMin + 3; - tr.chrg.cpMax = fi.chrgText.cpMin + 5; - m_log.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr); - - int bIconIndex = trbuffer[0] - '0'; - if (bIconIndex >= NR_LOGICONS) { - fi.chrg.cpMin = fi.chrgText.cpMax + 6; - continue; + tr.chrg.cpMin = fi.chrgText.cpMin + 3; + tr.chrg.cpMax = fi.chrgText.cpMin + 5; + m_log.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr); + + int bIconIndex = trbuffer[0] - '0'; + if (bIconIndex >= NR_LOGICONS) { + fi.chrg.cpMin = fi.chrgText.cpMax + 6; + continue; + } + + char bDirection = trbuffer[1]; + m_log.SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + COLORREF crDefault; + if (cf2.crBackColor != 0) + crDefault = cf2.crBackColor; + else if (bDirection == '>') + crDefault = (fAppend) ? m_pContainer->theme.outbg : m_pContainer->theme.oldoutbg; + else + crDefault = (fAppend) ? m_pContainer->theme.inbg : m_pContainer->theme.oldinbg; + + TLogIcon theIcon(Logicons[bIconIndex], crDefault); + CImageDataObject::InsertBitmap(ole, theIcon.m_hBmp); + fi.chrg.cpMin = cr.cpMax + 6; } - - char bDirection = trbuffer[1]; - m_log.SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); - COLORREF crDefault; - if (cf2.crBackColor != 0) - crDefault = cf2.crBackColor; - else if (bDirection == '>') - crDefault = (fAppend) ? m_pContainer->theme.outbg : m_pContainer->theme.oldoutbg; - else - crDefault = (fAppend) ? m_pContainer->theme.inbg : m_pContainer->theme.oldinbg; - - TLogIcon theIcon(Logicons[bIconIndex], crDefault); - CImageDataObject::InsertBitmap(ole, theIcon.m_hBmp); - fi.chrg.cpMin = cr.cpMax + 6; } } -- cgit v1.2.3