[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:
parent
2cb0038e08
commit
481b80909e
|
@ -55,6 +55,14 @@ void writeLog(const char *logFileName, const char *log2write)
|
|||
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)
|
||||
{
|
||||
char cleanedName[64] = "";
|
||||
|
|
|
@ -26,6 +26,8 @@ void systemMessage(const char *title);
|
|||
void printInt(int int2print);
|
||||
void printStr(const char *str2print);
|
||||
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);
|
||||
|
||||
#endif //M30_IDE_COMMUN_H
|
||||
|
|
|
@ -789,7 +789,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne) {
|
|||
_pluginsManager.notify(&scnN);
|
||||
|
||||
//add to recent files if its an existing file
|
||||
if (!buf->isUntitled())
|
||||
if (!buf->isUntitled() && PathFileExists(buf->getFilePath()))
|
||||
{
|
||||
_lastRecentFileList.add(buf->getFilePath());
|
||||
}
|
||||
|
|
|
@ -507,7 +507,6 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) {
|
|||
{
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
|
||||
|
||||
|
||||
char data[blockSize + 1];
|
||||
int lengthDoc = _pscratchTilla->getCurrentDocLen();
|
||||
for (int i = 0; i < lengthDoc; i += blockSize)
|
||||
|
@ -579,42 +578,48 @@ bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read
|
|||
const int blockSize = 128 * 1024; //128 kB
|
||||
char data[blockSize];
|
||||
|
||||
FILE *fp = fopen(filename, "rb");
|
||||
if (!fp)
|
||||
__try {
|
||||
FILE *fp = fopen(filename, "rb");
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
//Setup scratchtilla for new filedata
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc);
|
||||
bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0;
|
||||
if (ro) {
|
||||
_pscratchTilla->execute(SCI_SETREADONLY, false);
|
||||
}
|
||||
_pscratchTilla->execute(SCI_CLEARALL);
|
||||
if (language < L_EXTERNAL) {
|
||||
_pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID);
|
||||
} else {
|
||||
int id = language - L_EXTERNAL;
|
||||
char * name = NppParameters::getInstance()->getELCFromIndex(id)._name;
|
||||
_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name);
|
||||
}
|
||||
|
||||
size_t lenFile = 0;
|
||||
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
|
||||
do {
|
||||
lenFile = fread(data, 1, blockSize, fp);
|
||||
lenConvert = UnicodeConvertor->convert(data, lenFile);
|
||||
_pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf()));
|
||||
} while (lenFile > 0);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
|
||||
_pscratchTilla->execute(SCI_SETSAVEPOINT);
|
||||
if (ro) {
|
||||
_pscratchTilla->execute(SCI_SETREADONLY, true);
|
||||
}
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
|
||||
return true;
|
||||
|
||||
}__except(filter(GetExceptionCode(), GetExceptionInformation())) {
|
||||
printStr("File is too big to be opened by Notepad++");
|
||||
return false;
|
||||
|
||||
//Setup scratchtilla for new filedata
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc);
|
||||
bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0;
|
||||
if (ro) {
|
||||
_pscratchTilla->execute(SCI_SETREADONLY, false);
|
||||
}
|
||||
_pscratchTilla->execute(SCI_CLEARALL);
|
||||
if (language < L_EXTERNAL) {
|
||||
_pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID);
|
||||
} else {
|
||||
int id = language - L_EXTERNAL;
|
||||
char * name = NppParameters::getInstance()->getELCFromIndex(id)._name;
|
||||
_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name);
|
||||
}
|
||||
|
||||
size_t lenFile = 0;
|
||||
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
|
||||
do {
|
||||
lenFile = fread(data, 1, blockSize, fp);
|
||||
lenConvert = UnicodeConvertor->convert(data, lenFile);
|
||||
_pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf()));
|
||||
} while (lenFile > 0);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
|
||||
_pscratchTilla->execute(SCI_SETSAVEPOINT);
|
||||
if (ro) {
|
||||
_pscratchTilla->execute(SCI_SETREADONLY, true);
|
||||
}
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
BufferID FileManager::getBufferFromName(const char * name) {
|
||||
char fullpath[MAX_PATH];
|
||||
|
|
Loading…
Reference in New Issue