From: GiWoong Kim Date: Tue, 10 Mar 2015 07:21:22 +0000 (+0900) Subject: xml: parsing exception handling X-Git-Tag: TizenStudio_2.0_p3.0~306^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45a5715c5bd1f34ecb35b336bb20ce12998e7994;p=sdk%2Femulator%2Fqemu.git xml: parsing exception handling use display size as window size when normalImage has not defined add some logs Change-Id: I6d7cc911fa097b3a4e7e763d4f98feacbdd514e4 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/xmllayoutparser.cpp b/tizen/src/display/xmllayoutparser.cpp index f0b9fdd..e1accfc 100644 --- a/tizen/src/display/xmllayoutparser.cpp +++ b/tizen/src/display/xmllayoutparser.cpp @@ -166,6 +166,8 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml) QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString(); MainForm *form = new MainForm(formName); + qDebug() << form->getName() << "================"; + QXmlStreamReader::TokenType token = xml.readNext(); while (xml.atEnd() == false && (xml.name() == FORM_KEYWORD && @@ -180,15 +182,21 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml) QString normalImageFileName = xml.readElementText(); qDebug() << "- normalImage :" << normalImageFileName; - form->skinImg[MainForm::normal].load( - xmlPath + QDir::separator() + normalImageFileName); + if (normalImageFileName.isEmpty() == true) { + // TODO: general purpose skin + } else if (form->skinImg[MainForm::normal].load( + xmlPath + QDir::separator() + normalImageFileName) == false) { + qWarning() << "failed to load normal image"; + } } else if (xml.name() == "pressedImage") { /* key pressed image */ QString pressedImageFileName = xml.readElementText(); qDebug() << "- pressedImage :" << pressedImageFileName; - form->skinImg[MainForm::pressed].load( - xmlPath + QDir::separator() + pressedImageFileName); + if (form->skinImg[MainForm::pressed].load( + xmlPath + QDir::separator() + pressedImageFileName) == false) { + qWarning() << "failed to load pressed image"; + } } else if (xml.name() == "maskImage") { /* mask image */ // TODO: @@ -204,6 +212,8 @@ MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml) token = xml.readNext(); } + qDebug() << form->getName() << "================"; + return form; } @@ -472,6 +482,8 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml) ControllerForm *form = new ControllerForm( formName.isEmpty() ? xmlPath.section(QDir::separator(), -1) : formName); + qDebug() << form->getName() << "================"; + QXmlStreamReader::TokenType token = xml.readNext(); while (xml.atEnd() == false && (xml.name() == FORM_KEYWORD && @@ -483,15 +495,19 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml) QString normalImageFileName = xml.readElementText(); qDebug() << "- normalImage :" << normalImageFileName; - form->conImg[ControllerForm::normal].load( - xmlPath + QDir::separator() + normalImageFileName); + if (form->conImg[ControllerForm::normal].load( + xmlPath + QDir::separator() + normalImageFileName) == false) { + qWarning() << "failed to load normal image"; + } } else if (xml.name() == "pressedImage") { /* key pressed image */ QString pressedImageFileName = xml.readElementText(); qDebug() << "- pressedImage :" << pressedImageFileName; - form->conImg[ControllerForm::pressed].load( - xmlPath + QDir::separator() + pressedImageFileName); + if (form->conImg[ControllerForm::pressed].load( + xmlPath + QDir::separator() + pressedImageFileName) == false) { + qWarning() << "failed to load pressed image"; + } } else if (xml.name() == KEYLIST_KEYWORD) { /* HW keys */ int cnt = parseKeyList(xml, form->keyList); @@ -504,6 +520,8 @@ ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml) token = xml.readNext(); } + qDebug() << form->getName() << "================"; + return form; } diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index ddc2988..b649e07 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -323,9 +323,9 @@ void MainWindow::resizeEvent(QResizeEvent *event) void MainWindow::setRegion() { - //qDebug("set region"); - - setMask(uiInfo->getUiRegion()); + if (uiInfo->getUiRegion().isEmpty() == false) { + setMask(uiInfo->getUiRegion()); + } } void MainWindow::switchForm(int index) diff --git a/tizen/src/ui/uiinformation.cpp b/tizen/src/ui/uiinformation.cpp index 44d1d22..a60f0e1 100644 --- a/tizen/src/ui/uiinformation.cpp +++ b/tizen/src/ui/uiinformation.cpp @@ -74,7 +74,17 @@ QSize UIInformation::getMainSize() MainForm *mainForm = getMainForm(); if (mainForm == NULL) { qWarning("main form is null"); - return QSize(0, 0); + return QSize(100, 100); + } + + if (mainForm->skinImg[MainForm::normal].size() == QSize(0, 0)) { + qWarning("invalid normal image size"); + + if (mainForm->displayType->region.size() == QSize(0, 0)) { + return QSize(100, 100); + } else { + return mainForm->displayType->region.size() * uiState.getScaleFactor(); + } } return mainForm->skinImg[MainForm::normal].size() * uiState.getScaleFactor(); @@ -110,7 +120,7 @@ QRegion UIInformation::getMainRegion() MainForm *mainForm = getMainForm(); if (mainForm == NULL) { qWarning("main form is null"); - return QRegion(0, 0, 100, 100); + return QRegion(0, 0, 0, 0); } QImage *mainImage = &(mainForm->skinImg[MainForm::normal]);