Skip to content

Commit 0b367c4

Browse files
committed
[BUG_FIXED] Fix a crash issue while right-clicking on the doc switcher's column control ("Name" and "Ext.").
- Notepad-plus svn trunk @ 840
1 parent f39cc8e commit 0b367c4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
6666
{
6767
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
6868
int i = lpnmitem->iItem;
69-
7069
if (i == -1)
7170
{
72-
//::MessageBoxA(NULL, "oh yeh","",MB_OK);
7371
::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0);
7472
}
7573
return TRUE;
@@ -78,9 +76,9 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
7876
case NM_CLICK:
7977
{
8078
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
79+
int nbItem = ListView_GetItemCount(_fileListView.getHSelf());
8180
int i = lpnmitem->iItem;
82-
83-
if (i == -1)
81+
if (i == -1 || i >= nbItem)
8482
return TRUE;
8583

8684
LVITEM item;
@@ -97,8 +95,9 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
9795
{
9896
// Switch to the right document
9997
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
98+
int nbItem = ListView_GetItemCount(_fileListView.getHSelf());
10099
int i = lpnmitem->iItem;
101-
if (i == -1)
100+
if (i == -1 || i >= nbItem)
102101
return TRUE;
103102

104103
LVITEM item;
@@ -143,7 +142,6 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
143142
case VK_RETURN:
144143
{
145144
int i = ListView_GetSelectionMark(_fileListView.getHSelf());
146-
147145
if (i == -1)
148146
return TRUE;
149147

0 commit comments

Comments
 (0)