BEUG iterator

zolt4n

08-12-2007 15:45:42

I don't know why but it's not the first time that I have this bug.

so It's apear when I move mouse.

in Widget* Widget::getTargetWidget(const Point& pixelPosition)

for( it = mChildWidgets.begin(); it != mChildWidgets.end(); ++it )
{
if( (*it)->getQuadLayer() == Quad::LAYER_CHILD )
continue;

==> Widget* temp = (*it)->getTargetWidget(pixelPosition); <==
if( (temp != NULL) && (temp->getOffset() > widgetOffset) )
{
widgetOffset = temp->getOffset();
w = temp;
}
}


I find that is appear after delete object like that.

//tree is a list;
_tree->removeAndDestroyChild(_item);
_tree->removeAndDestroyChild(_thumbtails);
_tree->removeAndDestroyChild(_minus);

kungfoomasta

08-12-2007 20:47:59

Can you post the call stack at time of crash? Stepping into getTargetWidget to see where it crashes would also be good. I would guess that a child was destroyed but not removed from the child list. (dangling pointer) I can't be sure without more information..

zolt4n

08-12-2007 22:42:42

call stack is not very expresive


> QuickGUI_d.dll!QuickGUI::Widget::getTargetWidget(const QuickGUI::Point & pixelPosition={312, 512}) Line 707 + 0x24 bytes C++
QuickGUI_d.dll!QuickGUI::Sheet::getTargetWidget(const QuickGUI::Point & pixelPosition={...}) Line 108 + 0x29 bytes C++
QuickGUI_d.dll!QuickGUI::GUIManager::injectMouseMove(const int & xPixelOffset=11, const int & yPixelOffset=-18) Line 617 + 0x19 bytes C++
GML_Debug.exe!InputManager::mouseMoved(const OIS::MouseEvent & arg={...}) Line 207 + 0x22 bytes C++
OIS_d.dll!1001c969()
[Frames below may be incorrect and/or missing, no symbols loaded for OIS_d.dll]

kungfoomasta

08-12-2007 22:47:46

Can you step into this? Or in the very least, when it crashes, what is the value of this? Is it 0x0000?

zolt4n

08-12-2007 22:51:49

I can't because I use it as a library but (*it) is unreadable but "it" is good pointer

//// after ////
now I compile with your code.
and this = my tree object it's not null
but it from mChildWidgets is conrupted,

probably
removeAndDestroy is not very good ???

zolt4n

09-12-2007 00:31:42

that sure that the widget that I have delete previously is always in the vector contenair ...

kungfoomasta

09-12-2007 07:50:24

Destruction of widgets are not destroyed immediately most the time. Widgets are Queued for deletion, the actual destruction occurs after the GUIManager renders the GUI. So in code, if you perform operations on the list right after you destroy the widget, it will still be there. It will be gone next frame though.

Just to be more clear on the issue, are you saying
1. there is a pointer to widget that doesn't exist because it's been deleted,
or
2. the widget is in the list but I have already made a call to removeAndDestroy
?

I don't currently have the time to investigate this. If you can reproduce this in the demo it will speed up finding out the cause of this.

zolt4n

09-12-2007 14:02:59

the first one