나는 일반적으로 루핑에 빠지지 않습니다. 그러나 루핑 논리에서는 여기에 우둔한 것처럼 보입니다. inner for 루프에 중단을 넣을 때 얻을 수있는 값은 항상 0입니다. 그러나 break를 제거하면 올바른 값을 얻습니다. 내 코드에서 무엇이 잘못 되었습니까?QT의 foreach 루프가이 예제에서 작동하지 않습니까?
void ContentCache::getAggregatorList()
{
TLOG_FUNC_ENTER();
ContentAggregator *aggregator = ContentAggregator::Instance();
QList <ContentID> aggContentList;
/* Get the service list from the aggregator */
aggregator->getContentList(CONTENT_TYPE_LIVE_SERVICE, aggContentList);
QList<Attribute> attributeListOut;
ContentID content;
foreach(content, aggContentList)
{
TLOG_INFO("SJ..main loop");
//if(content.source == TERRESTRIAL_BROADCAST_SOURCE)
// {
doGetServiceAttributes(content,attributeListOut);
unsigned int attributeIndex = 0;
foreach(Attribute attr, attributeListOut)
{
TLOG_INFO("SJ..Inner loop");
if(attr.name == "chanNum")
{
TLOG_INFO("SJ..The attr channelNum is = "<<attr.value.toInt());
if(attr.value.toUInt() == 999)
{
TLOG_INFO("SJ..The changed attr channelNum is"<<attr.value.toUInt());
attr.name = "chanNum";
attr.value = 200;
attributeListOut.replace(attributeIndex,attr);
TLOG_INFO("SJ..The changed attr channelNum is"<<attr.value.toUInt());
m_cacheDB->terrestrialUpdateService(content,attributeListOut);
}
else
{
TLOG_INFO("SJ..The unmodified attr channelNum is"<<attr.value.toUInt());
}
break;
}
attributeIndex++;
// }
}
}
// getAttributeValues(ContentID id, QList<QString> value, QList<Attribute> &attributeListOut);
}*
네트워킹을 만드십니까? 그렇다면, 어쩌면 당신은 속보를하는 동안 약간의 응답을 놓칠 수 있습니까? – vahancho
당신이 추적하고있는 변수입니다 (즉 :'break'와 "right values"를 0으로 줄 것입니다)? – fritzone
attr.value.toInt() –