destroy bug

huaner

17-07-2007 15:14:34

hi:
i create a window at first, then destroy it. all is right, but if you move mouse, there is a bug and curson hinting the function of mouseMove
and the error is:
std::bad_alloc at memory location.
please, how to deal with it?

kungfoomasta

17-07-2007 21:52:02

Sounds like a bug. It could be that the active widget or mouse over widget was the window, and after the window was deleted, the code was using pointers to garbage data. I will have to debug and reproduce this when I can.

Thanks for bringing this to my attention, I'll look into it when I have the opportunity. :wink:

huaner

18-07-2007 02:41:03

Sounds like a bug. It could be that the active widget or mouse over widget was the window, and after the window was deleted, the code was using pointers to garbage data. I will have to debug and reproduce this when I can.

Thanks for bringing this to my attention, I'll look into it when I have the opportunity. :wink:

yes, if destroy another window not itsself, it's all right. if i want to reslove it, can you give some advice?
aslo, i found if i put somethings in the TextBox, and any character is a hot key(for example, if is KC_N, i use it to translate a node, and i put 'n' in the textBox, it will crash, maybe conflict?

kungfoomasta

18-07-2007 03:19:04

Are you saying you are destroying the window from within the code of the same window? I should make the sheet destroy the window, but not immediately. The Sheet::timeElapsed function should check for windows queued for deletion and remove them. Also, I still have to work with the GUIManager, it needs to check if its pointers point to this widget about to be deleted. Another good idea. :)

i found if i put somethings in the TextBox, and any character is a hot key(for example, if is KC_N, i use it to translate a node, and i put 'n' in the textBox, it will crash, maybe conflict?

The textbox will have text input if it is the active widget (has focus). You can click outside the textbox and pressing KC_N will do nothing. :wink:

huaner

18-07-2007 07:26:40

Are you saying you are destroying the window from within the code of the same window?
yes, i'm very sorry that you have to bear my poor writting english.
eg: i create 2 windows. the first have 2 buttons, one is destroying itself, the other is destroying the second window. if do first button, it crash,and error is std::bad_alloc; but do second button, is all right.
Also, I still have to work with the GUIManager, it needs to check if its pointers point to this widget about to be deleted.
yes,we can get the widget's demension, and check the curson's position that Vector2 mousePos = QuickGUI::MouseCursor::getSingleton().getPixelPosition();
mousePos.x/float(arg.state.width), mousePos.y/float(arg.state.height)
is inside it.is right?

The Sheet::timeElapsed function should check for windows queued for deletion and remove them.

i'am very sorry that i don't exprehend

kungfoomasta

18-07-2007 08:28:01

What I meant was that the GUIManager detects and uses pointers to widgets. If the widget is destroyed, I need to set the point to NULL, so GUIManager doesn't try to use it.

For the last part, I am talking about a safe way to delete windows. We should avoid using "delete myWindow;" and instead use functions like mDefaultSheet->destroyWindow(myWindow);

huaner

18-07-2007 09:07:13


What I meant was that the GUIManager detects and uses pointers to widgets. If the widget is destroyed, I need to set the point to NULL, so GUIManager doesn't try to use it.

i get all widgets which are belong to destroy's window, and set the point to null, but it crash when mouse move.