From: GiWoong Kim Date: Tue, 8 Sep 2015 10:19:11 +0000 (+0900) Subject: xml: modified error message for skin loading failure X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~130 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5608fe9444bbd9cc679a683c6fcb96713e2469e;p=sdk%2Femulator%2Fqemu.git xml: modified error message for skin loading failure Change-Id: I944ba391081a056a26deb5798bacc808b7cc74eb Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index c8b6610749..59a1e83bdf 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -47,7 +47,7 @@ bool is_display_off(void); //using namespace std; void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &); -void loadMainFormFromXML(QFile *, UIInformation *); +void loadMainFormFromXML(QString, UIInformation *); void loadConFormFromXML(QFile *, UIInformation *); bool qt5IsOnscreen; @@ -121,16 +121,13 @@ void qt5_gui_init(void) } qDebug() << "VM path:" << uiInfo->vmDataPath; - uiInfo->skinPath = QDir( - QString::fromLocal8Bit(get_emul_skin_path())).canonicalPath(); - if (uiInfo->skinPath.endsWith(QDir::separator()) == false) { - uiInfo->skinPath += QDir::separator(); - } + uiInfo->skinPath = QDir::toNativeSeparators( + QString::fromLocal8Bit(get_emul_skin_path())); qDebug() << "skin path:" << uiInfo->skinPath; /* read skin information */ - QSettings skinInfo(uiInfo->skinPath + LAYOUT_SKIN_INFO_FILE, - QSettings::IniFormat); + QSettings skinInfo(uiInfo->skinPath + QDir::separator() + + LAYOUT_SKIN_INFO_FILE, QSettings::IniFormat); QString skinName = skinInfo.value(SKIN_PROPERTY_NAME).toString(); if (skinName.isEmpty() == true) { skinName = GENERIC_TEXT_UNDEFINED; @@ -143,12 +140,12 @@ void qt5_gui_init(void) uiInfo->vmDataPath + GUI_PROPERTIES_FILE, QSettings::IniFormat); /* XML layout */ - QFile mainXMLFile(uiInfo->skinPath + LAYOUT_FORM_FILE_NAME); /* load main form */ - loadMainFormFromXML(&mainXMLFile, uiInfo); + loadMainFormFromXML(uiInfo->skinPath + QDir::separator() + + LAYOUT_FORM_FILE_NAME, uiInfo); - QDir skinDir(uiInfo->skinPath + LAYOUT_CON_FORM_SUBPATH); /* load controller forms */ + QDir skinDir(uiInfo->skinPath + QDir::separator() + LAYOUT_CON_FORM_SUBPATH); QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); if (entries.isEmpty() == false) { @@ -464,68 +461,66 @@ void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QSt } } -void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */) +void loadMainFormFromXML(QString xmlPath, UIInformation *uiInfo/* out */) { - if (file->exists() == false) { - qFatal("%s %s", qPrintable(file->fileName()), MSG_NOT_FOUND); - return; - } + QFile file(xmlPath); - if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) { - qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2); + if (file.exists() == false || + file.open(QIODevice::ReadOnly | QIODevice::Text) == false) { + qFatal("Failed to load the emulator skin. %s%s", MSG_CHECK_PATH, + qPrintable(xmlPath)); return; } - qDebug("main form is loaded from %s", qPrintable(file->fileName())); + qDebug("main form is loaded from %s", qPrintable(file.fileName())); /* read xml */ - QFileInfo fileInfo(*file); - QXmlStreamReader xml(file); + QXmlStreamReader xml(&file); /* parse xml */ + QFileInfo fileInfo(xmlPath); XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo); QString version = parser.parseEmulatorUI(xml); - qDebug() << "layout version :" << version; + qDebug() << "layout version:" << version; const bool hasError = xml.hasError(); xml.clear(); - file->close(); + file.close(); if (hasError == true) { - qFatal(MSG_INVALID_XML_FORMAT); + qFatal("%s %s%s", MSG_INVALID_XML_FORMAT, MSG_CHECK_PATH, + qPrintable(xmlPath)); return; } } void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */) { - if (file->exists() == false) { - qWarning("%s is not found", qPrintable(file->fileName())); - return; - } - - if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) { - qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2); + if (file->exists() == false || + file->open(QIODevice::ReadOnly | QIODevice::Text) == false) { + qWarning() << "Failed to load the controller skin:" << + file->fileName(); return; } qDebug("controller form is loaded from %s", qPrintable(file->fileName())); /* read xml */ - QFileInfo fileInfo(*file); QXmlStreamReader xml(file); /* parse xml */ + QFileInfo fileInfo(*file); XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo); QString version = parser.parseControllerUI(xml); - qDebug() << "layout version :" << version; + qDebug() << "layout version:" << version; const bool hasError = xml.hasError(); xml.clear(); file->close(); - if (hasError == true) { - qFatal(MSG_INVALID_XML_FORMAT); + if (hasError == false) { + qFatal("%s %s%s", MSG_INVALID_XML_FORMAT, MSG_CHECK_PATH, + qPrintable(fileInfo.absoluteFilePath())); return; } } diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h index 22c4eb8962..e86c3cbd3e 100644 --- a/tizen/src/ui/resource/ui_strings.h +++ b/tizen/src/ui/resource/ui_strings.h @@ -130,12 +130,15 @@ #define MSG_CLOSE_POPUP "Do you really want to quit this program?" /* qFatal messages */ -#define MSG_INTERNAL_ERR "An internal error occurred.\n: " +#define MSG_INTERNAL_ERR "An internal error occurred : \n\n" +#define MSG_CHECK_PATH "Check if the file is corrupted or missing from the following path.\n" + +// TODO: refine #define MSG_EMULATOR_EXIT "\n\nEmulator will now exit." #define MSG_INVALID_MAIN_FORM "main form is null" #define MSG_NOT_FOUND "is not found" #define MSG_NOT_OPEN_1 "Couldn't open" #define MSG_NOT_OPEN_2 "file" -#define MSG_INVALID_XML_FORMAT "Invalid XML format" +#define MSG_INVALID_XML_FORMAT "Invalid XML format, the file cannot be loaded." #endif // UI_STRINGS_H