[BUG_FIXED] Fix the huge file makes notepad++ crash issue.

Fix adding item in the history file list while deleting file from Notepad++  bug.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@290 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-07-17 07:35:39 +00:00
parent 2cb0038e08
commit 481b80909e
4 changed files with 52 additions and 37 deletions

View File

@ -55,6 +55,14 @@ void writeLog(const char *logFileName, const char *log2write)
fclose(f); fclose(f);
} }
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep)
{
if (code == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand) std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand)
{ {
char cleanedName[64] = ""; char cleanedName[64] = "";

View File

@ -26,6 +26,8 @@ void systemMessage(const char *title);
void printInt(int int2print); void printInt(int int2print);
void printStr(const char *str2print); void printStr(const char *str2print);
void writeLog(const char *logFileName, const char *log2write); void writeLog(const char *logFileName, const char *log2write);
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);
std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand = false); std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand = false);
#endif //M30_IDE_COMMUN_H #endif //M30_IDE_COMMUN_H

View File

@ -789,7 +789,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne) {
_pluginsManager.notify(&scnN); _pluginsManager.notify(&scnN);
//add to recent files if its an existing file //add to recent files if its an existing file
if (!buf->isUntitled()) if (!buf->isUntitled() && PathFileExists(buf->getFilePath()))
{ {
_lastRecentFileList.add(buf->getFilePath()); _lastRecentFileList.add(buf->getFilePath());
} }

View File

@ -507,7 +507,6 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) {
{ {
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
char data[blockSize + 1]; char data[blockSize + 1];
int lengthDoc = _pscratchTilla->getCurrentDocLen(); int lengthDoc = _pscratchTilla->getCurrentDocLen();
for (int i = 0; i < lengthDoc; i += blockSize) for (int i = 0; i < lengthDoc; i += blockSize)
@ -579,6 +578,7 @@ bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read
const int blockSize = 128 * 1024; //128 kB const int blockSize = 128 * 1024; //128 kB
char data[blockSize]; char data[blockSize];
__try {
FILE *fp = fopen(filename, "rb"); FILE *fp = fopen(filename, "rb");
if (!fp) if (!fp)
return false; return false;
@ -615,6 +615,11 @@ bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read
} }
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return true; return true;
}__except(filter(GetExceptionCode(), GetExceptionInformation())) {
printStr("File is too big to be opened by Notepad++");
return false;
}
} }
BufferID FileManager::getBufferFromName(const char * name) { BufferID FileManager::getBufferFromName(const char * name) {
char fullpath[MAX_PATH]; char fullpath[MAX_PATH];