Commit 23bf39d1 authored by LM's avatar LM

Fixed small bug in XML generation error handling

parent 33da8692
......@@ -18,13 +18,13 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) :
{
m_ui->setupUi(this);
// Now set syntax highlighter
//highlighter = new MAVLinkSyntaxHighlighter(m_ui->xmlTextView->document());
connect(m_ui->selectFileButton, SIGNAL(clicked()), this, SLOT(selectXMLFile()));
connect(m_ui->selectOutputButton, SIGNAL(clicked()), this, SLOT(selectOutputDirectory()));
connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generate()));
connect(m_ui->saveButton, SIGNAL(clicked()), this, SLOT(save()));
// Make sure text background is white
m_ui->xmlTextView->setStyleSheet("QGCMAVLinkTextEdit { background-color: #FFFFFF; }");
}
void XMLCommProtocolWidget::selectXMLFile()
......@@ -128,7 +128,11 @@ void XMLCommProtocolWidget::generate()
m_ui->compileLog->clear();
// Check XML validity
if (!m_ui->xmlTextView->syntaxcheck()) return;
if (!m_ui->xmlTextView->syntaxcheck())
{
// Syntax check already gives output
return;
}
MAVLinkXMLParser* parser = new MAVLinkXMLParser(m_ui->fileNameLabel->text().trimmed(), m_ui->outputDirNameLabel->text().trimmed());
connect(parser, SIGNAL(parseState(QString)), m_ui->compileLog, SLOT(appendHtml(QString)));
......
......@@ -50,32 +50,32 @@ void QGCMAVLinkTextEdit::setPlainText( const QString txt )
bool QGCMAVLinkTextEdit::syntaxcheck()
{
bool error = false;
bool noError = true;
if (text().size() > 0 ) {
QString errorStr;
int errorLine, errorColumn;
QDomDocument doc;
if (!doc.setContent(text(),false, &errorStr, &errorLine, &errorColumn)) {
//////return doc.toString(5);
QMessageBox::information(0, tr("Found xml error"),tr("Check line %1 column %2 on string \"%3\"!")
QMessageBox::critical(0, tr("Found xml error"),tr("Check line %1 column %2 on string \"%3\"!")
.arg(errorLine - 1)
.arg(errorColumn - 1)
.arg(errorStr));
error = true;
noError = false;
// FIXME Mark line
if (errorLine >= 0 ) {
}
} else {
QMessageBox::information(0, tr("XML valid."),tr("All tag are valid size %1.").arg(text().size()));
QMessageBox::information(0, tr("XML valid."),tr("All tags are valid. Document size is %1 characters.").arg(text().size()));
setPlainText(doc.toString(5));
}
} else {
QMessageBox::information(0, tr("XML not found!"),tr("Null size xml document!"));
error = true;
noError = false;
}
return error;
return noError;
}
void QGCMAVLinkTextEdit::contextMenuEvent ( QContextMenuEvent * e )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment