beug report

zolt4n

11-01-2008 15:46:28

Hello all i just find a bug.

In my application I use QuickGui::Button

and if I click over a button I destroy all QuickGui::Button and load another scene.

if when the QuickGui::Buttonis deleted my mouse button is allways pushed down over QuickGui::ButtonI got a segfault in


bool Widget::fireEvent(Event e, EventArgs& args)
{
if(mUserEventHandlers[e].empty() && !mPropogateEventFiring[e])

line 895 of quickguiWidget.cpp

enjoy ;)

kungfoomasta

11-01-2008 17:41:29

The event handler is registered for mouse down or up? How are you destroying the button? Why not post the code in your button handler?

kungfoomasta

12-01-2008 00:16:32

I think I know the problem for this, should be an easy fix.

zolt4n

12-01-2008 09:27:21

in fact i don't use the button handler.

I just look at the mouse position and button on mouse (click)

I destroy my button like that _Guimanager->destroyWidget(_Widget);

kungfoomasta

12-01-2008 17:50:43

Ok I'm confused. Can you please post relevant code?

Give me the exact code I need to reproduce this in the demo.

zolt4n

14-01-2008 10:31:49

the code is a little long but is same this:


void beugfunction(QuickGui::button *button)
{
if (mouseclickover(button)
{
destroy(button);
loadAnOtherButton();
}
}

void destroy(QuickGui::Widget *button)
{
_guiManager->destroyWidget(button);
}
void loop()
{
while (42)
beugfunction(_curentButton);
// I checked if _currentButton is the good one
}

kungfoomasta

14-01-2008 17:39:10

You aren't making it very easy for me to help you..

1. Post the code for function "loadAnOtherButton"

2. Give me the call stack when the crash occurs.

3. Give me the exact code needed to reproduce this in the demo.

If you at least provide me with 3, and assuming it is reproducible on my end, I can fix this. Otherwise you're just using up all my time..

zolt4n

14-01-2008 18:11:42

callstack =

> QuickGUI_d.dll!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::size() Line 703 + 0x3 bytes C++
QuickGUI_d.dll!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::empty() Line 713 + 0x8 bytes C++
QuickGUI_d.dll!QuickGUI::Widget::fireEvent(QuickGUI::Widget::Event e=EVENT_MOUSE_LEAVE, QuickGUI::EventArgs & args={...}) Line 895 + 0x15 bytes C++
QuickGUI_d.dll!QuickGUI::Widget::fireEvent(QuickGUI::Widget::Event e=EVENT_MOUSE_LEAVE, QuickGUI::EventArgs & args={...}) Line 928 C++
QuickGUI_d.dll!QuickGUI::GUIManager::injectMouseMove(const int & xPixelOffset=19, const int & yPixelOffset=-27) Line 587 + 0x14 bytes C++
QuickGUI_d.dll!QuickGUI::GUIManager::injectMousePosition(const int & xPixelPosition=275, const int & yPixelPosition=114) Line 605 C++
GML_Debug.exe!GmlOgre3D::mouseMoved(const OIS::MouseEvent & arg={...}) Line 631 + 0x22 bytes C++
GML_Debug.exe!InputManager::mouseMoved(const OIS::MouseEvent & arg={...}) Line 228 + 0x22 bytes C++




my code


QuickGUI::Button *createButton()
{
static bool bl = true;

std::string name = "b1";
if (!bl)
name = "b2";
QuickGUI::Sheet *mSheet = _guiManager->getDefaultSheet();
quickGui::button *button=mSheet->createButton(name);
button->setText(name);
if (bl)
button->setPosition(0, 0);
else
button->setPosition(100, 100);
bl != bl;
return button;
}

....
QuickGUI::Button *button;
while (42)
{

if (mouseisOverButton(button))
{
_guiManager->destroyWidget(button);
button = createButton();
}
}



So every other time I have a button name "b1" and "b2".
It does not bug every time but if you change button 15 -20 times the bug appear, ...

I don't know more sory

Zini

14-01-2008 18:39:21

This


QuickGUI::Button *button;
while (42)
{

if (mouseisOverButton(button))
{
_guiManager->destroyWidget(button);
button = createButton();
}
}


is bogus, because when the while loop is entered the first time, button points to nothing. Therefore you have undefined behaviour and anything that goes wrong is your own problem.

And since we're at it:


bl != bl;


doesn't make sense either. You probably meant:


bl = !bl;

kungfoomasta

14-01-2008 18:56:27

Good call!

The call stack suggests a crash occurs because the mouse has moved. I reviewed some older code regarding how I destroy widgets, and if the current code is similar, there might be an issue. I will look at this when I get home later.

zolt4n

17-01-2008 16:37:57

sorry for I bug my-slef ;)

I wrote
...
QuickGUI::Button *button;

in fact it is

QuickGUI::Button *button;
.... /* tralala And initalisation of button ;) */

and
bl != bl
is
bl = !bl

;)

// if I have time I will create a new project and try to recreate this bug

zolt4n

18-01-2008 14:59:47

Ha in fact I try durring this 2 days to reproduce this bug in a simple exemple, and I just find how do it .

the bug occured in my prg when my fps is slow (like 20 30fps)

so I find a way to do a small code with this bug

http://bordet.b.free.fr/dl/QuickGUIDemo.h

download it here !!!

thx U

zolt4n

18-01-2008 15:06:01

just a short explanation of my code

in frame listener I check

if button is clicked I delete It and create Button2
else if button 2 is clicked I delete It and create Button1

that all stay clicking on button and after 2 sec BAMMMMMMMMMMM

;0

kungfoomasta

18-01-2008 18:05:12

Ok I see your new code, I'll give it a shot tonight or tomorrow and see what I find.