Is it a bug??
Is it a bug??
IGUIButton* mybutton=0;
mybutton=env->addButton(rect<s32>(35,35,140,50), 0, 104, L"Close Window");
mybutton->remove();// When add this,it comes out a Assertion msgbox,info :_BLOCK_TYPE_IS_VALID(PHead->nBlockUse
I would like to know if it is a bug or my fault way to call "remove" function?[/b]
mybutton=env->addButton(rect<s32>(35,35,140,50), 0, 104, L"Close Window");
mybutton->remove();// When add this,it comes out a Assertion msgbox,info :_BLOCK_TYPE_IS_VALID(PHead->nBlockUse
I would like to know if it is a bug or my fault way to call "remove" function?[/b]
it does not work
In the example :UserInterface,
I add code in the main() as follow:
mybutton=env->addButton(rect<s32>(35,35,140,50), 0, 104, L"Close Window");
mybutton->drop();
mybutton is a global var.It works well.
Then I move the "mybutton->drop();" to
class MyEventReceiver : public IEventReceiver
public:
virtual bool OnEvent(SEvent event)
{
case EGET_BUTTON_CLICKED:
.......
if (id == 102)
{
mybutton->drop();
return true;
}
........
}
when I click the button whose id is 102, it comes out a assertion .
why can not drop it? any mistake I am?
I add code in the main() as follow:
mybutton=env->addButton(rect<s32>(35,35,140,50), 0, 104, L"Close Window");
mybutton->drop();
mybutton is a global var.It works well.
Then I move the "mybutton->drop();" to
class MyEventReceiver : public IEventReceiver
public:
virtual bool OnEvent(SEvent event)
{
case EGET_BUTTON_CLICKED:
.......
if (id == 102)
{
mybutton->drop();
return true;
}
........
}
when I click the button whose id is 102, it comes out a assertion .
why can not drop it? any mistake I am?
Look at the documentation for addButton:
remove() should normaly do it!
What's the exact error/assertion again? (Can't really get it from your first post.)
This is because the guienv still has a pointer to it and will have a problem if you drop it manually.Returns a pointer to the created button. Returns 0 if an error occured.
This pointer should not be dropped. See IUnknown::drop() for more information.
remove() should normaly do it!
What's the exact error/assertion again? (Can't really get it from your first post.)
Last edited by jox on Wed Jul 14, 2004 2:21 pm, edited 1 time in total.
jox, it came out a msgbox,said:access to only readable memory.
eqinzm,but getRootGUIElement() is not a interfare of
IGUIEnvironment. In the construction of CGUIEnvironment,I get that:
CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IEventReceiver* userReceiver)
: IGUIElement(0, 0, 0, core::rect<s32>(core::position2d<s32>(0,0), driver ? driver->getScreenSize() : core::dimension2d<s32>(0,0))),
UserReceiver(userReceiver), Hovered(0), CurrentSkin(0), Driver(driver),
MouseFocus(0), KeyFocus(0), FileSystem(fs)
{
...
}
eqinzm,you means get a handle to the
IGUIElement(0, 0, 0, core::rect<s32>(core::position2d<s32>(0,0), driver ? driver->getScreenSize() : core::dimension2d<s32>(0,0)))
and then try to removeChild(myButton) ?
eqinzm,but getRootGUIElement() is not a interfare of
IGUIEnvironment. In the construction of CGUIEnvironment,I get that:
CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IEventReceiver* userReceiver)
: IGUIElement(0, 0, 0, core::rect<s32>(core::position2d<s32>(0,0), driver ? driver->getScreenSize() : core::dimension2d<s32>(0,0))),
UserReceiver(userReceiver), Hovered(0), CurrentSkin(0), Driver(driver),
MouseFocus(0), KeyFocus(0), FileSystem(fs)
{
...
}
eqinzm,you means get a handle to the
IGUIElement(0, 0, 0, core::rect<s32>(core::position2d<s32>(0,0), driver ? driver->getScreenSize() : core::dimension2d<s32>(0,0)))
and then try to removeChild(myButton) ?
look
D:\irrlicht-0.6\include\IGUIEnvironment.h
//! Returns the root gui element. This is the first gui element, parent of all other
//! gui elements. You'll never need to use this method, unless you are not creating
//! your own gui elements, trying to add them to the gui elements without a parent.
//! The returned pointer should not be dropped. See IUnknown::drop() for more information.
virtual IGUIElement* getRootGUIElement() = 0;
code:
gui::IGUIEnvironment *mpGuiEnv;
mpGuiEnv->getRootGUIElement()->removeChild(mpButton);
//! Returns the root gui element. This is the first gui element, parent of all other
//! gui elements. You'll never need to use this method, unless you are not creating
//! your own gui elements, trying to add them to the gui elements without a parent.
//! The returned pointer should not be dropped. See IUnknown::drop() for more information.
virtual IGUIElement* getRootGUIElement() = 0;
code:
gui::IGUIEnvironment *mpGuiEnv;
mpGuiEnv->getRootGUIElement()->removeChild(mpButton);
getRootGUIElement()->removeChild(mpButton) might work. But it also might not work if the button is not child of the root element, but child of another element (window, toolbar, ...).
button->remove() also calls removeChild(button), but it calls it with the actual parent (be it the root or another).
button->remove() should really do it. I get no error if I create a button and then remove() it. I'm afraid there's something else wrong in your code.
button->remove() also calls removeChild(button), but it calls it with the actual parent (be it the root or another).
Code: Select all
//! Removes this element.
virtual void remove()
{
if (Parent)
Parent->removeChild(this);
}
I got the answer :)
The bug is really one in version irrlicht-0.41.(I downloaded it several months ago)
I update the engine to vertion 0.6,and it works well now .
thanks for all guys.especially jox and eqinzm.
but here comes a new bug in 0.6 about modal messagebox.I have post it in another thread.
I update the engine to vertion 0.6,and it works well now .
thanks for all guys.especially jox and eqinzm.
but here comes a new bug in 0.6 about modal messagebox.I have post it in another thread.
Re: I got the answer :)
Anonymous wrote:The bug is really one in version irrlicht-0.41.(I downloaded it several months ago)
anyway you're welcome...
(but next time better check version before posting a bug! (or at least mention the version))