fixed a bug in musredit_startup.xml and added proper error handling in the XML handler
This commit is contained in:
@ -416,6 +416,66 @@ bool PAdminXMLParser::endDocument()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param exception
|
||||
*/
|
||||
bool PAdminXMLParser::warning( const QXmlParseException & exception )
|
||||
{
|
||||
QString msg;
|
||||
|
||||
msg = QString("**WARNING** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
|
||||
msg += QString("**WARNING MESSAGE** ") + exception.message();
|
||||
|
||||
qWarning() << endl << msg << endl;
|
||||
|
||||
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param exception
|
||||
*/
|
||||
bool PAdminXMLParser::error( const QXmlParseException & exception )
|
||||
{
|
||||
QString msg;
|
||||
|
||||
msg = QString("**ERROR** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
|
||||
msg += QString("**ERROR MESSAGE** ") + exception.message();
|
||||
|
||||
qWarning() << endl << msg << endl;
|
||||
|
||||
QMessageBox::critical(0, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param exception
|
||||
*/
|
||||
bool PAdminXMLParser::fatalError( const QXmlParseException & exception )
|
||||
{
|
||||
QString msg;
|
||||
|
||||
msg = QString("**FATAL ERROR** while parsing musredit_startup.xml in line no %1\n").arg(exception.lineNumber());
|
||||
msg += QString("**FATAL ERROR MESSAGE** ") + exception.message();
|
||||
|
||||
qWarning() << endl << msg << endl;
|
||||
|
||||
QMessageBox::critical(0, "FATAL ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Expands system variables to full path, e.g. <tt>$HOME -> \home\user</tt>
|
||||
@ -510,7 +570,12 @@ PAdmin::PAdmin()
|
||||
QXmlInputSource source( &xmlFile );
|
||||
QXmlSimpleReader reader;
|
||||
reader.setContentHandler( &handler );
|
||||
reader.parse( source );
|
||||
reader.setErrorHandler( &handler );
|
||||
if (!reader.parse( source )) {
|
||||
QMessageBox::critical(0, "ERROR",
|
||||
"Error parsing musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
|
||||
QMessageBox::Ok, QMessageBox::NoButton);
|
||||
}
|
||||
} else {
|
||||
QMessageBox::critical(0, "ERROR",
|
||||
"Couldn't find the musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
|
||||
|
@ -86,6 +86,10 @@ class PAdminXMLParser : public QXmlDefaultHandler
|
||||
bool characters(const QString&);
|
||||
bool endDocument();
|
||||
|
||||
bool warning( const QXmlParseException & exception );
|
||||
bool error( const QXmlParseException & exception );
|
||||
bool fatalError( const QXmlParseException & exception );
|
||||
|
||||
QString expandPath(const QString&);
|
||||
|
||||
EAdminKeyWords fKeyWord; ///< key word tag to know how to handle the content
|
||||
|
@ -46,7 +46,7 @@
|
||||
<create_msr_file_only>n</create_msr_file_only>
|
||||
<fit_only>n</fit_only>
|
||||
<global>n</global>
|
||||
</msr2data_default>
|
||||
</msr2data_defaults>
|
||||
<func_pixmap_path>$HOME/analysis/musrfit/src/musredit/latex_images</func_pixmap_path>
|
||||
<theory_functions>
|
||||
<func>
|
||||
@ -198,4 +198,3 @@
|
||||
</func>
|
||||
</theory_functions>
|
||||
</musredit_startup>
|
||||
|
||||
|
Reference in New Issue
Block a user