0
我做以下,並獲得該調試錯誤:爲什麼我得到矢量迭代器不兼容?
AguiWidgetBase* AguiWidgetContainer::recursiveGetWidgetUnderMouse(
AguiWidgetBase* root, const AguiMouseEventArgs &mouse)
{
AguiWidgetBase* currentNode = root;
bool foundsomething = true;
while(foundsomething)
{
foundsomething = false;
if(currentNode->getChildCntrolCount() > 0)
for (std::vector<AguiWidgetBase*>::const_reverse_iterator rit =
currentNode->getChildRBeginIterator();
rit < currentNode->getChildREndIterator(); ++rit)
{
if(!foundsomething)
if ((*rit)->intersectionWithPoint(mouse.getPosition()))
{
foundsomething = true;
currentNode = *rit;
}
}
}
return currentNode;
}
// ...
它currentNode成爲一個指向根的一個孩子後,並在爲崩潰失敗。
我在做什麼錯?
謝謝
我該如何解決這個問題? – jmasterx 2010-10-16 02:20:28
@Milo - 看我的編輯。在內部if語句中添加一個break語句,以便短路for循環。但是,不要重新指定迭代器開始。如果你覺得你必須使用不同的變量! – wheaties 2010-10-16 02:21:33