Improved support for large files
This commit is contained in:
parent
d9a84f61d2
commit
9eee9ccdf9
|
@ -34,6 +34,7 @@ void *ValidationThread::Entry()
|
||||||
|
|
||||||
if ( TestDestroy() )
|
if ( TestDestroy() )
|
||||||
{
|
{
|
||||||
|
myBuffer.clear();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +44,8 @@ void *ValidationThread::Entry()
|
||||||
mySystem,
|
mySystem,
|
||||||
this );
|
this );
|
||||||
|
|
||||||
|
myBuffer.clear();
|
||||||
|
|
||||||
if ( TestDestroy() )
|
if ( TestDestroy() )
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
#include "xmlschemagenerator.h"
|
#include "xmlschemagenerator.h"
|
||||||
#include "threadreaper.h"
|
#include "threadreaper.h"
|
||||||
|
#include <wx/wupdlock.h>
|
||||||
|
|
||||||
#define ngettext wxGetTranslation
|
#define ngettext wxGetTranslation
|
||||||
|
|
||||||
|
@ -2926,7 +2927,9 @@ void MyFrame::newDocument ( const std::string& s, const wxString& path, bool can
|
||||||
|
|
||||||
wxString auxPath = getAuxPath ( path );
|
wxString auxPath = getAuxPath ( path );
|
||||||
|
|
||||||
Freeze();
|
{
|
||||||
|
wxWindowUpdateLocker noupdate (this);
|
||||||
|
|
||||||
doc = ( s.empty() ) ?
|
doc = ( s.empty() ) ?
|
||||||
new XmlDoc (
|
new XmlDoc (
|
||||||
mainBook,
|
mainBook,
|
||||||
|
@ -2949,7 +2952,7 @@ void MyFrame::newDocument ( const std::string& s, const wxString& path, bool can
|
||||||
path,
|
path,
|
||||||
auxPath );
|
auxPath );
|
||||||
mainBook->AddPage ( ( wxWindow * ) doc, documentLabel );
|
mainBook->AddPage ( ( wxWindow * ) doc, documentLabel );
|
||||||
Thaw();
|
}
|
||||||
|
|
||||||
mainBook->Layout();
|
mainBook->Layout();
|
||||||
|
|
||||||
|
@ -3061,21 +3064,17 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
bool fileEmpty = false;
|
bool fileEmpty = false;
|
||||||
|
|
||||||
statusProgress ( _T ( "Opening file..." ) );
|
statusProgress ( _T ( "Opening file..." ) );
|
||||||
//wxMemoryMappedFile *memorymap = NULL;
|
BinaryFile binaryfile ( fileName );
|
||||||
BinaryFile *binaryfile = NULL;
|
if ( !binaryfile.getData() )
|
||||||
|
|
||||||
binaryfile = new BinaryFile ( fileName );
|
|
||||||
if ( !binaryfile->getData() )
|
|
||||||
{
|
{
|
||||||
wxString message;
|
wxString message;
|
||||||
message.Printf ( _ ( "Cannot open %s" ), fileName.c_str() );
|
message.Printf ( _ ( "Cannot open %s" ), fileName.c_str() );
|
||||||
messagePane ( message, CONST_STOP );
|
messagePane ( message, CONST_STOP );
|
||||||
statusProgress ( wxEmptyString );
|
statusProgress ( wxEmptyString );
|
||||||
delete binaryfile;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
memorymap = new wxMemoryMappedFile(
|
//wxMemoryMappedFile memorymap (
|
||||||
fileName,
|
fileName,
|
||||||
true, // readOnly
|
true, // readOnly
|
||||||
true // fread
|
true // fread
|
||||||
|
@ -3093,8 +3092,8 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
|
|
||||||
if ( !fileEmpty )
|
if ( !fileEmpty )
|
||||||
{
|
{
|
||||||
docBuffer = ( char * ) binaryfile->getData();//memorymap->GetStream();
|
docBuffer = ( char * ) binaryfile.getData();//memorymap->GetStream();
|
||||||
docBufferLen = binaryfile->getDataLen();//memorymap->GetMapSize();
|
docBufferLen = binaryfile.getDataLen();//memorymap->GetMapSize();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3112,7 +3111,11 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
size_t finalBufferLen;
|
size_t finalBufferLen;
|
||||||
|
|
||||||
std::string encoding;
|
std::string encoding;
|
||||||
if ( docBufferLen >= 4 && // UTF-32 BE
|
if ( largeFile )
|
||||||
|
{
|
||||||
|
encoding = "UTF-8";
|
||||||
|
}
|
||||||
|
else if ( docBufferLen >= 4 && // UTF-32 BE
|
||||||
( unsigned char ) docBuffer[0] == 0x00 &&
|
( unsigned char ) docBuffer[0] == 0x00 &&
|
||||||
( unsigned char ) docBuffer[1] == 0x00 &&
|
( unsigned char ) docBuffer[1] == 0x00 &&
|
||||||
( unsigned char ) docBuffer[2] == 0xFE &&
|
( unsigned char ) docBuffer[2] == 0xFE &&
|
||||||
|
@ -3192,7 +3195,6 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
wideEncoding.c_str() );
|
wideEncoding.c_str() );
|
||||||
messagePane ( message, CONST_STOP );
|
messagePane ( message, CONST_STOP );
|
||||||
delete binaryfile;//memorymap;
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3216,7 +3218,16 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
size_t iconvBufferLeft, docBufferLeft;
|
size_t iconvBufferLeft, docBufferLeft;
|
||||||
iconvBufferLen = iconvBufferLeft = docBufferLen * iconvLenMultiplier + 1;
|
iconvBufferLen = iconvBufferLeft = docBufferLen * iconvLenMultiplier + 1;
|
||||||
docBufferLeft = docBufferLen;
|
docBufferLeft = docBufferLen;
|
||||||
iconvBuffer.extend ( iconvBufferLen );
|
if ( ( ( ( size_t ) -1 ) - 1 ) / iconvLenMultiplier < docBufferLen
|
||||||
|
|| !iconvBuffer.extend ( iconvBufferLen ) )
|
||||||
|
{
|
||||||
|
wxString message;
|
||||||
|
message.Printf ( _ ( "Cannot open %s: out of memory" ),
|
||||||
|
fileName.c_str() );
|
||||||
|
messagePane ( message, CONST_STOP );
|
||||||
|
statusProgress ( wxEmptyString );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
finalBuffer = buffer = iconvBuffer.data(); // buffer will be incremented by iconv
|
finalBuffer = buffer = iconvBuffer.data(); // buffer will be incremented by iconv
|
||||||
nconv = reinterpret_cast < universal_iconv & > ( iconv ) (
|
nconv = reinterpret_cast < universal_iconv & > ( iconv ) (
|
||||||
cd,
|
cd,
|
||||||
|
@ -3236,20 +3247,21 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
wideEncoding.c_str() );
|
wideEncoding.c_str() );
|
||||||
messagePane ( message, CONST_STOP );
|
messagePane ( message, CONST_STOP );
|
||||||
delete binaryfile; //delete memorymap;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finalBufferLen = iconvBufferLen - iconvBufferLeft;
|
finalBufferLen = iconvBufferLen - iconvBufferLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusProgress ( _ ( "Creating document view..." ) );
|
statusProgress ( _ ( "Creating document view..." ) );
|
||||||
Freeze();
|
{
|
||||||
|
wxWindowUpdateLocker noupdate ( this );
|
||||||
|
|
||||||
doc = new XmlDoc (
|
doc = new XmlDoc (
|
||||||
mainBook,
|
mainBook,
|
||||||
( largeFile ) ? largeFileProperties: properties,
|
( largeFile ) ? largeFileProperties: properties,
|
||||||
&protectTags,
|
&protectTags,
|
||||||
visibilityState,
|
visibilityState,
|
||||||
( !binaryfile->getDataLen() ) ? FILE_TYPE_XML : type,
|
( !binaryfile.getDataLen() ) ? FILE_TYPE_XML : type,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
finalBuffer,
|
finalBuffer,
|
||||||
finalBufferLen,
|
finalBufferLen,
|
||||||
|
@ -3270,7 +3282,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
doc->setLastModified ( ofn.GetModificationTime() );
|
doc->setLastModified ( ofn.GetModificationTime() );
|
||||||
|
|
||||||
mainBook->AddPage ( ( wxWindow * ) doc, name, _T ( "" ) );
|
mainBook->AddPage ( ( wxWindow * ) doc, name, _T ( "" ) );
|
||||||
Thaw();
|
}
|
||||||
statusProgress ( wxEmptyString );
|
statusProgress ( wxEmptyString );
|
||||||
|
|
||||||
mainBook->Layout();
|
mainBook->Layout();
|
||||||
|
@ -3279,9 +3291,8 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
doc->setLastModified ( fn.GetModificationTime() );
|
doc->setLastModified ( fn.GetModificationTime() );
|
||||||
doc->SetFocus();
|
doc->SetFocus();
|
||||||
|
|
||||||
if ( type != FILE_TYPE_XML || !binaryfile->getDataLen() )
|
if ( type != FILE_TYPE_XML || !binaryfile.getDataLen() )
|
||||||
{
|
{
|
||||||
delete binaryfile;//memorymap;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3346,7 +3357,6 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
||||||
{
|
{
|
||||||
closePane();
|
closePane();
|
||||||
}
|
}
|
||||||
delete binaryfile; //delete memorymap;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ XmlCtrl::XmlCtrl (
|
||||||
currentMaxLine = 1;
|
currentMaxLine = 1;
|
||||||
|
|
||||||
applyProperties ( propertiesParameter );
|
applyProperties ( propertiesParameter );
|
||||||
|
applyVisibilityState ( visibilityState );
|
||||||
|
|
||||||
SetTabWidth ( 2 );
|
SetTabWidth ( 2 );
|
||||||
SetWrapStartIndent ( 2 );
|
SetWrapStartIndent ( 2 );
|
||||||
|
@ -118,7 +119,6 @@ XmlCtrl::XmlCtrl (
|
||||||
SetUndoCollection ( true );
|
SetUndoCollection ( true );
|
||||||
AutoCompSetSeparator ( '<' );
|
AutoCompSetSeparator ( '<' );
|
||||||
|
|
||||||
applyVisibilityState ( visibilityState );
|
|
||||||
lineBackgroundState = BACKGROUND_STATE_NORMAL;
|
lineBackgroundState = BACKGROUND_STATE_NORMAL;
|
||||||
|
|
||||||
for ( int i = 0; i < wxSTC_INDIC_MAX; ++i )
|
for ( int i = 0; i < wxSTC_INDIC_MAX; ++i )
|
||||||
|
|
Loading…
Reference in New Issue