From 3366d54204749fc7f9330a444ad068d9adb10570 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Wed, 11 Nov 2015 20:09:45 +0900 Subject: [PATCH] XML: print specified error cases while parsing - UnexpectedElementError - NotWellFormedError - PrematureEndOfDocumentError Change-Id: Iaf80dfb40cc0167636fa190172991ef10a4f8f9a Signed-off-by: GiWoong Kim --- tizen/src/ui/qt5_supplement.cpp | 15 ++++++++++----- tizen/src/ui/xmllayoutparser.cpp | 32 ++++++++++++++++++++++++++++++++ tizen/src/ui/xmllayoutparser.h | 2 ++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index 2b33ba515c..ed39643b24 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -453,13 +453,18 @@ void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QSt fprintf(stderr, "%s|%5d|S|%10.10s|%4u|%s\n", dateMsg.constData(), qemu_get_thread_id(), fname.trimmed().constData(), context.line, localMsg.trimmed().constData()); + { + QString err; + QMessageBox::critical(0, EMULATOR_TITLE, + QString(MSG_INTERNAL_ERR) + + err.sprintf("%s", (localMsg.trimmed()).constData()) + + MSG_EMULATOR_EXIT); + } - QString err; - QMessageBox::critical(0, EMULATOR_TITLE, - QString(MSG_INTERNAL_ERR) + - err.sprintf("%s", (localMsg.trimmed()).constData()) + - MSG_EMULATOR_EXIT); abort(); + default: + qFatal("invalid message type"); + break; } } diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index a7c841909e..2b016ecacb 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -555,6 +555,10 @@ QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml) } } + if (xml.hasError() == true) { + printError(xml.error()); + } + return layoutVersion; } @@ -652,6 +656,10 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml) } } + if (xml.hasError() == true) { + printError(xml.error()); + } + return layoutVersion; } @@ -679,3 +687,27 @@ void XmlLayoutParser::makeGeneralCon(ControllerForm *form) form->setCenteralRect(painter.getCenteralRect()); form->setGeneralPurpose(true); } + +void XmlLayoutParser::printError(QXmlStreamReader::Error err) +{ + switch (err) { + case QXmlStreamReader::NoError: + /* do nothing */ + break; + case QXmlStreamReader::UnexpectedElementError: + qCritical("The parser encountered an element that was different to those it expected."); + break; + case QXmlStreamReader::CustomError: + qCritical("A custom error has been raised with raiseError()"); + break; + case QXmlStreamReader::NotWellFormedError: + qCritical("The parser internally raised an error due to the read XML not being well-formed."); + break; + case QXmlStreamReader::PrematureEndOfDocumentError: + qCritical("The input stream ended before a well-formed XML document was parsed."); + break; + default: + qFatal("invalid error type"); + break; + } +} diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h index de643d10cd..1a8840a755 100644 --- a/tizen/src/ui/xmllayoutparser.h +++ b/tizen/src/ui/xmllayoutparser.h @@ -70,6 +70,8 @@ private: ControllerForm *parseControllerForm(QXmlStreamReader &xml); void makeGeneralCon(ControllerForm *form); + void printError(QXmlStreamReader::Error err); + QString xmlPath; UiInformation *uiInfo; }; -- 2.34.1