Is it a bug??

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Nick
Posts: 4
Joined: Fri Feb 06, 2004 3:55 am

Is it a bug??

Post by Nick »

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]
Guest

Post by Guest »

try this:
mybutton->drop();
Nick
Posts: 4
Joined: Fri Feb 06, 2004 3:55 am

it does not work

Post by Nick »

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?
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Look at the documentation for addButton:
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.
This is because the guienv still has a pointer to it and will have a problem if you drop it manually.

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.
eqinzm
Posts: 3
Joined: Sat Apr 03, 2004 5:42 pm

try this

Post by eqinzm »

pGuiEnv->getRootGUIElement()->removeChild(myButton);
Nick
Posts: 4
Joined: Fri Feb 06, 2004 3:55 am

Post by Nick »

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
Posts: 3
Joined: Sat Apr 03, 2004 5:42 pm

look

Post by eqinzm »

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);
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

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).

Code: Select all

	//! Removes this element.
	virtual void remove()
	{
		if (Parent)
			Parent->removeChild(this);
	}
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.
Guest

I got the answer :)

Post by Guest »

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.
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Re: I got the answer :)

Post by jox »

Anonymous wrote:The bug is really one in version irrlicht-0.41.(I downloaded it several months ago)
:shock:

anyway you're welcome... :)
(but next time better check version before posting a bug! (or at least mention the version))
Guest

Post by Guest »

jox,ok,I will take care.
Post Reply