Don't initialize/terminate Xerces-C++ over and over again. It leads to crash when several files are opened on startup. This could be the root cause of some startup crashes, e.g. bug #2787738 and bug #2825812.
This commit is contained in:
parent
bfd582bdd1
commit
6d6ade623e
|
@ -33,14 +33,6 @@ using namespace xercesc;
|
|||
|
||||
WrapXerces::WrapXerces( std::string catalogPath, std::string catalogUtilityPath )
|
||||
{
|
||||
try
|
||||
{
|
||||
XMLPlatformUtils::Initialize();
|
||||
}
|
||||
catch ( XMLException& e )
|
||||
{
|
||||
throw std::runtime_error ( "Cannot initialize Xerces" );
|
||||
}
|
||||
errorPosition = std::make_pair ( 1, 1 );
|
||||
catalogResolver = new XercesCatalogResolver( catalogPath, catalogUtilityPath );
|
||||
}
|
||||
|
@ -48,7 +40,6 @@ WrapXerces::WrapXerces( std::string catalogPath, std::string catalogUtilityPath
|
|||
WrapXerces::~WrapXerces()
|
||||
{
|
||||
delete catalogResolver;
|
||||
XMLPlatformUtils::Terminate();
|
||||
}
|
||||
|
||||
bool WrapXerces::validate ( const std::string& fileName )
|
||||
|
|
|
@ -312,6 +312,9 @@ MyApp::~MyApp()
|
|||
delete checker;
|
||||
delete server;
|
||||
delete connection;
|
||||
|
||||
// Terminate Xerces-C++
|
||||
XMLPlatformUtils::Terminate();
|
||||
}
|
||||
|
||||
bool MyApp::OnInit()
|
||||
|
@ -371,6 +374,10 @@ bool MyApp::OnInit()
|
|||
{
|
||||
wxImage::AddHandler ( new wxPNGHandler );
|
||||
wxSystemOptions::SetOption ( _T ( "msw.remap" ), 0 );
|
||||
|
||||
// Initialize Xerces-C++
|
||||
XMLPlatformUtils::Initialize();
|
||||
|
||||
frame = new MyFrame (
|
||||
_ ( "XML Copy Editor" ),
|
||||
config.get(),
|
||||
|
@ -381,6 +388,14 @@ bool MyApp::OnInit()
|
|||
if ( frame->getHandleCommandLineFlag() )
|
||||
frame->handleCommandLine();
|
||||
}
|
||||
catch ( const XMLException &e )
|
||||
{
|
||||
wxString error;
|
||||
error << _ ( "Failed to initialize Xerces-c:\n" )
|
||||
<< WrapXerces::toString ( e.getMessage() );
|
||||
wxMessageBox ( error, _ ( "Error" ), wxOK | wxICON_ERROR );
|
||||
return false;
|
||||
}
|
||||
catch ( exception &e )
|
||||
{
|
||||
const char *what;
|
||||
|
|
|
@ -435,17 +435,6 @@ void XmlPromptGenerator::handleSchema (
|
|||
|
||||
std::string schemaPath = PathResolver::run ( path, ( d->auxPath.empty() ) ? d->basePath : d->auxPath);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
XMLPlatformUtils::Initialize();
|
||||
}
|
||||
catch ( const XMLException& toCatch )
|
||||
{
|
||||
XMLPlatformUtils::Terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
XercesDOMParser *parser = new XercesDOMParser();
|
||||
parser->setDoNamespaces ( true );
|
||||
parser->setDoSchema ( true );
|
||||
|
@ -455,8 +444,7 @@ void XmlPromptGenerator::handleSchema (
|
|||
if ( !rootGrammar )
|
||||
{
|
||||
delete parser;
|
||||
XMLPlatformUtils::Terminate();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
SchemaGrammar* grammar = ( SchemaGrammar* ) rootGrammar;
|
||||
|
@ -466,7 +454,6 @@ void XmlPromptGenerator::handleSchema (
|
|||
{
|
||||
delete grammar;
|
||||
delete parser;
|
||||
XMLPlatformUtils::Terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -526,7 +513,6 @@ void XmlPromptGenerator::handleSchema (
|
|||
}
|
||||
}
|
||||
delete parser;
|
||||
XMLPlatformUtils::Terminate();
|
||||
}
|
||||
|
||||
void XmlPromptGenerator::getContent (
|
||||
|
|
Loading…
Reference in New Issue