From 1d91debf07bc12ba6b2dc242e0984b07c46cda4e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 13 Feb 2020 14:47:43 +0300 Subject: fixes #2210 (TabSRMM: crash on Quote button) --- plugins/TabSRMM/src/msgdialog.cpp | 23 ++++++++++++++--------- plugins/TabSRMM/src/version.h | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index af564e8b6f..5b80be58eb 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -947,9 +947,20 @@ void CMsgDialog::onClick_Quote(CCtrlButton*) if (hDBEvent == 0) return; - CHARRANGE sel; - LOG()->WndProc(EM_EXGETSEL, 0, (LPARAM)&sel); - if (sel.cpMin == sel.cpMax) { + bool bUseSelection = false; + if (m_iLogMode == 0) { + CHARRANGE sel; + LOG()->WndProc(EM_EXGETSEL, 0, (LPARAM)&sel); + if (sel.cpMin != sel.cpMax) { + ptrA szFromStream(LOG()->GetRichTextRtf(true, true)); + ptrW converted(mir_utf8decodeW(szFromStream)); + Utils::FilterEventMarkers(converted); + m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, ptrW(QuoteText(converted))); + bUseSelection = true; + } + } + + if (!bUseSelection) { DBEVENTINFO dbei = {}; dbei.cbBlob = db_event_getBlobSize(hDBEvent); wchar_t *szText = (wchar_t*)mir_alloc((dbei.cbBlob + 1) * sizeof(wchar_t)); // URLs are made one char bigger for crlf @@ -991,12 +1002,6 @@ void CMsgDialog::onClick_Quote(CCtrlButton*) if (bNeedsFree) mir_free(szConverted); } - else { - ptrA szFromStream(LOG()->GetRichTextRtf(true, true)); - ptrW converted(mir_utf8decodeW(szFromStream)); - Utils::FilterEventMarkers(converted); - m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, ptrW(QuoteText(converted))); - } SetFocus(m_message.GetHwnd()); } diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h index da35591b32..fd58768343 100644 --- a/plugins/TabSRMM/src/version.h +++ b/plugins/TabSRMM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3 #define __MINOR_VERSION 6 #define __RELEASE_NUM 0 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include -- cgit v1.2.3