[BUG_FIXED] Fix "finds in all opened files" crash bug.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@615 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
1bab772c37
commit
99042edb28
@ -242,7 +242,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||
int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, 0);
|
||||
if (len > 0)
|
||||
{
|
||||
if (len > int(_wideCharAllocLen))
|
||||
if ((size_t)len > _wideCharAllocLen)
|
||||
{
|
||||
delete [] _wideCharStr;
|
||||
_wideCharAllocLen = len;
|
||||
@ -256,42 +256,51 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||
return _wideCharStr;
|
||||
}
|
||||
|
||||
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
|
||||
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
|
||||
// which are converted to the corresponding indexes in the returned wchar_t string.
|
||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
|
||||
{
|
||||
if (!_wideCharStr)
|
||||
{
|
||||
_wideCharStr = new wchar_t[initSize];
|
||||
_wideCharAllocLen = initSize;
|
||||
}
|
||||
if (!_wideCharStr)
|
||||
{
|
||||
_wideCharStr = new wchar_t[initSize];
|
||||
_wideCharAllocLen = initSize;
|
||||
}
|
||||
|
||||
int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, 0);
|
||||
if (len > 0)
|
||||
{
|
||||
if (len > int(_wideCharAllocLen))
|
||||
{
|
||||
delete [] _wideCharStr;
|
||||
_wideCharAllocLen = len;
|
||||
_wideCharStr = new wchar_t[_wideCharAllocLen];
|
||||
}
|
||||
len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len);
|
||||
*mstart = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mstart, _wideCharStr, 0);
|
||||
*mend = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mend, _wideCharStr, 0);
|
||||
if (*mstart >= len || *mend >= len)
|
||||
{
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_wideCharStr[0] = 0;
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
return _wideCharStr;
|
||||
}
|
||||
int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, 0);
|
||||
if (len > 0)
|
||||
{
|
||||
if (len > int(_wideCharAllocLen))
|
||||
{
|
||||
delete [] _wideCharStr;
|
||||
_wideCharAllocLen = len;
|
||||
_wideCharStr = new wchar_t[_wideCharAllocLen];
|
||||
}
|
||||
len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len);
|
||||
|
||||
if ((size_t)*mstart < strlen(mbcs2Convert) && (size_t)*mend < strlen(mbcs2Convert))
|
||||
{
|
||||
*mstart = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mstart, _wideCharStr, 0);
|
||||
*mend = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mend, _wideCharStr, 0);
|
||||
if (*mstart >= len || *mend >= len)
|
||||
{
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_wideCharStr[0] = 0;
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
return _wideCharStr;
|
||||
}
|
||||
|
||||
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage)
|
||||
{
|
||||
@ -304,7 +313,7 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
|
||||
int len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, 0, NULL, NULL);
|
||||
if (len > 0)
|
||||
{
|
||||
if (len > int(_multiByteAllocLen))
|
||||
if ((size_t)len > _multiByteAllocLen)
|
||||
{
|
||||
delete [] _multiByteStr;
|
||||
_multiByteAllocLen = len;
|
||||
@ -329,20 +338,29 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
|
||||
int len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, 0, NULL, NULL);
|
||||
if (len > 0)
|
||||
{
|
||||
if (len > int(_multiByteAllocLen))
|
||||
if ((size_t)len > _multiByteAllocLen)
|
||||
{
|
||||
delete [] _multiByteStr;
|
||||
_multiByteAllocLen = len;
|
||||
_multiByteStr = new char[_multiByteAllocLen];
|
||||
}
|
||||
len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); // not needed?
|
||||
*mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, _multiByteStr, 0, NULL, NULL);
|
||||
*mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, _multiByteStr, 0, NULL, NULL);
|
||||
if (*mstart >= len || *mend >= len)
|
||||
{
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
|
||||
if ((int)*mstart < lstrlen(wcharStr2Convert) && (int)*mend < lstrlen(wcharStr2Convert))
|
||||
{
|
||||
*mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, _multiByteStr, 0, NULL, NULL);
|
||||
*mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, _multiByteStr, 0, NULL, NULL);
|
||||
if (*mstart >= len || *mend >= len)
|
||||
{
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*mstart = 0;
|
||||
*mend = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
_multiByteStr[0] = 0;
|
||||
|
@ -211,7 +211,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
|
||||
{
|
||||
case WM_NCACTIVATE:
|
||||
{
|
||||
/* activate/deactivate titlebar of toolbars */
|
||||
// activate/deactivate titlebar of toolbars
|
||||
for (size_t iCont = DOCKCONT_MAX; iCont < _vContainer.size(); iCont++)
|
||||
{
|
||||
::SendMessage(_vContainer[iCont]->getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1);
|
||||
@ -258,7 +258,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
|
||||
if (::GetActiveWindow() != _hParent)
|
||||
break;
|
||||
|
||||
/* set respective activate state */
|
||||
// set respective activate state
|
||||
for (int i = 0; i < DOCKCONT_MAX; i++)
|
||||
{
|
||||
_vContainer[i]->SetActive(IsChild(_vContainer[i]->getHSelf(), ::GetFocus()));
|
||||
@ -276,7 +276,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
|
||||
|
||||
case DMM_MOVE_SPLITTER:
|
||||
{
|
||||
INT offset = (INT)wParam;
|
||||
int offset = wParam;
|
||||
|
||||
for (int iCont = 0; iCont < DOCKCONT_MAX; iCont++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user