From deb3b8fcfe2ac28dbed4d3be5a55c2a2fbd3049a Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 13 Feb 2015 23:30:34 +0000 Subject: [PATCH] [BUG_FIXED] (Author: Andreas Jonsson) Fix the crash issue while user Ctrl + double click on an empty document. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1342 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppNotification.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 258c80532..2f8fea9c2 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -486,7 +486,14 @@ BOOL Notepad_plus::notify(SCNotification *notification) const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI(); std::string bufstring; + unsigned int position_of_click; + // For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1. + // In that case we use SCI_GETCURRENTPOS to get the position. + if (notification->position != -1) + position_of_click = notification->position; + else + position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS)); // Anonymous scope to limit use of the buf pointer (much easier to deal with std::string). { @@ -499,13 +506,6 @@ BOOL Notepad_plus::notify(SCNotification *notification) length = notifyView->execute(SCI_GETLENGTH); buf = new char[length + 1]; notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf); - - // For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1. - // In that case we use SCI_GETCURRENTPOS to get the position. - if(notification->position != -1) - position_of_click = notification->position; - else - position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS)); } else { @@ -516,7 +516,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) // Compute the position of the click (relative to the beginning of the line). const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber()); - position_of_click = notification->position - line_position; + position_of_click = position_of_click - line_position; } bufstring = buf;