Fixed crash if the applist did not contain certain info about the app

This commit is contained in:
Diego Waxemberg 2015-02-10 15:48:29 -05:00
parent e31df3f44e
commit 0a767767fb

View File

@ -70,16 +70,26 @@ static const char* TAG_APP_IS_RUNNING = "IsRunning";
while (appInfoNode != NULL) {
if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_TITLE)) {
xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1);
if (nodeVal != NULL) {
appName = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding];
xmlFree(nodeVal);
} else {
appName = @"";
}
} else if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_ID)) {
xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1);
if (nodeVal != NULL) {
appId = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding];
xmlFree(nodeVal);
}
} else if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_IS_RUNNING)) {
xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1);
if (nodeVal != NULL) {
appIsRunning = [[[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding] isEqualToString:@"1"];
xmlFree(nodeVal);
} else {
appIsRunning = NO;
}
}
appInfoNode = appInfoNode->next;
}
@ -87,8 +97,10 @@ static const char* TAG_APP_IS_RUNNING = "IsRunning";
app.appName = appName;
app.appId = appId;
app.isRunning = appIsRunning;
if (app.appId != nil) {
[_appList addObject:app];
}
}
node = node->next;
}