xml: modified error message for skin loading failure
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 8 Sep 2015 10:19:11 +0000 (19:19 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 9 Sep 2015 07:34:54 +0000 (16:34 +0900)
Change-Id: I944ba391081a056a26deb5798bacc808b7cc74eb
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/qt5_supplement.cpp
tizen/src/ui/resource/ui_strings.h

index c8b66107497883aaa031a4ec76cdfa33d59ed4fa..59a1e83bdf44935f3941206e4870098a10f97810 100644 (file)
@@ -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;
     }
 }
index 22c4eb89628db9a4d4c9e35771031fc0b2133084..e86c3cbd3e0e88893ffbde9023971d95317822fd 100644 (file)
 #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