Improve resource error logging
Actually display the name of the item or the filename of the item
that we were unable to load in the log to make it easier to
determine what went wrong.
Change-Id: I027b35aab286e4d0f1957bcfb28ed40d81f9bbb2
diff --git a/gui/resources.cpp b/gui/resources.cpp
index 5f3923d..74f020b 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -149,8 +149,10 @@
std::string file;
mSurface = NULL;
- if (!node)
+ if (!node) {
+ LOGERR("ImageResource node is NULL\n");
return;
+ }
if (node->first_attribute("filename"))
file = node->first_attribute("filename")->value();
@@ -261,10 +263,13 @@
FontResource* res = new FontResource(child, pZip);
if (res == NULL || res->GetResource() == NULL)
{
- xml_attribute<>* attr_name = child->first_attribute("name");
+ std::string res_name;
+ if (child->first_attribute("name"))
+ res_name = child->first_attribute("name")->value();
+ if (res_name.empty() && child->first_attribute("filename"))
+ res_name = child->first_attribute("filename")->value();
- if (!attr_name) {
- std::string res_name = attr_name->value();
+ if (!res_name.empty()) {
LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
} else
LOGERR("Resource type (%s) failed to load\n", type.c_str());
@@ -281,10 +286,13 @@
ImageResource* res = new ImageResource(child, pZip);
if (res == NULL || res->GetResource() == NULL)
{
- xml_attribute<>* attr_name = child->first_attribute("name");
+ std::string res_name;
+ if (child->first_attribute("name"))
+ res_name = child->first_attribute("name")->value();
+ if (res_name.empty() && child->first_attribute("filename"))
+ res_name = child->first_attribute("filename")->value();
- if (!attr_name) {
- std::string res_name = attr_name->value();
+ if (!res_name.empty()) {
LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
} else
LOGERR("Resource type (%s) failed to load\n", type.c_str());
@@ -301,10 +309,13 @@
AnimationResource* res = new AnimationResource(child, pZip);
if (res == NULL || res->GetResource() == NULL)
{
- xml_attribute<>* attr_name = child->first_attribute("name");
+ std::string res_name;
+ if (child->first_attribute("name"))
+ res_name = child->first_attribute("name")->value();
+ if (res_name.empty() && child->first_attribute("filename"))
+ res_name = child->first_attribute("filename")->value();
- if (!attr_name) {
- std::string res_name = attr_name->value();
+ if (!res_name.empty()) {
LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
} else
LOGERR("Resource type (%s) failed to load\n", type.c_str());