Sasha Ponkratov - 2008-04-21

Hi,

Notepad++ crashes if you try to open huge file (280 mb log file in my case).
In debug version Notepad++ shows Error message box and opnes only part of the huge file.
In release build - just crashes with access violation os screen.

As quick fix i suggest you to disable undo collection while opening files. It will use less memory and will skip unneeded "undo collection" steps. It works for me (of course it doesn't fix the error message issue in release version, but it allows opening files with less memory overhead).
=)

I can be done this way:
//npp.4.8.5.src\PowerEditor\src\Notepad_plus.cpp, line 694 bool Notepad_plus::doOpen(const char *fileName, bool isReadOnly)

...
...

        // It's VERY IMPORTANT to reset the view
        _pEditView->execute(SCI_CLEARALL);
//////Sasha: Add this line to disable undo collection
                _pEditView->execute(SCI_SETUNDOCOLLECTION, 0, 0);

        char data[blockSize];
        size_t lenFile = fread(data, 1, sizeof(data), fp);
        bool isNotEmpty = (lenFile != 0);

        while (lenFile > 0)
        {
            lenFile = UnicodeConvertor.convert(data, lenFile);
            _pEditView->execute(SCI_ADDTEXT, lenFile, reinterpret_cast<LPARAM>(UnicodeConvertor.getNewBuf()));
            lenFile = int(fread(data, 1, sizeof(data), fp));
        }
        fclose(fp);

        // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
        (_pEditView->getCurrentBuffer()).determinateFormat(isNotEmpty?UnicodeConvertor.getNewBuf():(char *)(""));
        _pEditView->execute(SCI_SETEOLMODE, _pEditView->getCurrentBuffer().getFormat());

        // detect if it's a binary file (non ascii file)
        //(_pEditView->getCurrentBuffer()).detectBin(isNotEmpty?UnicodeConvertor.getNewBuf():(char *)(""));

        UniMode unicodeMode = static_cast<UniMode>(UnicodeConvertor.getEncoding());
        (_pEditView->getCurrentBuffer()).setUnicodeMode(unicodeMode);

        if (unicodeMode != uni8Bit)
            // Override the code page if Unicode
            _pEditView->execute(SCI_SETCODEPAGE, SC_CP_UTF8);

        if (isReadOnly)
            (_pEditView->getCurrentBuffer()).setReadOnly(true);

        _pEditView->getFocus();
        _pEditView->execute(SCI_SETSAVEPOINT);
        _pEditView->execute(EM_EMPTYUNDOBUFFER);
//////Sasha: File is loaded, it's time to enable undo collection
                _pEditView->execute(SCI_SETUNDOCOLLECTION, 1, 0);

...
...