Removal of GUI element causing heap validation error

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
WingedWarrior
Posts: 8
Joined: Mon Nov 10, 2003 2:34 pm

Removal of GUI element causing heap validation error

Post by WingedWarrior »

Hi all

Has any one successfully remove a gui element?

Using Visual C++ (Visual Studio .NET 2002) the following code:

//From the TechDemo tutorial...
gui::IGUIStaticText* statusText;
statusText = ...getGUIEnvironment()->addStaticText(L"Loading...",true, pos);
//Now, try removing it, and...
statusText->remove();

causes me to get a '_CrtIsValidHeapPointer exception :? , in the irrList class, within method erase, calling delete on it.current. The pointer looks to be a valid address.

Any ideas ?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Are you using version 0.4.1? This was a bug, which was fixed in 0.4.1. But if you are using 0.4.1, maybe there is another bug..
WingedWarrior
Posts: 8
Joined: Mon Nov 10, 2003 2:34 pm

Post by WingedWarrior »

Hi Niko

Yeah, sorry :roll: . I am using version 0.4. I didn;t realise 0.4.1 was availble for download, but see that it is :lol: .

Cheers

PS - Whats the best way to request features??? I have a rough but working 3rd Person Camera that you may want to take a look at, and some ideas for the GUI class. Thanks again.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

The best way to request features is simply posting them right in here :)

3rd Person camera is nice, and what ideas do you have for the gui?
WingedWarrior
Posts: 8
Joined: Mon Nov 10, 2003 2:34 pm

Post by WingedWarrior »

Hi Niko,

My ideas are nothing really startling, but would hopefully make for a more feature rich GUI. I'll list a couple of things below that I have been playing around with.

1) I have exposed another method on the CGUIButton class (setOverrideColor) which allows a second text color to be added. The primary use for this is to change the text color when the mouse cursor is over the button (Visual Highlighing etc). This could be added to other classed derived from CGUIElement.

2) A child device that has NO title bar and system menu. This way game menus can exist seperatly with out interferring with the actual game objects, etc. This is heading toward the same affect that Diablo II has when you enter one of its game menu (ie, A window with No title bar, transparent, and characters / world goes into pause mode). I can't work out how to do this will one device!

3) Some kind of callback system (using function pointers) to directly intercept SEvent objects.

4) Another idea, (I haven't but a lot of thought into this one) would be tooltips, (ie Mouse hovers over the GUIElement for a few seconds then displays a nice piece of text.)

Thats about all for the moment on the GUI. I will endevour to tidy up my 3rd person camera and post it, however after downloading version 0.4.1 I see you have added a Key Mapping for the FPS Camera, so will attempt to add this also (was on my list of things to do/request).

Keep up the excellant work.

Cheers
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Nice ideas, I already planned to implement some of them, like tooltips.
I fixed lots of bugs in the GUI system, so it is in the next version really easy to to extend the it. If you are createing lots of new widgets, think about creating them without modifing the engines code, in this way you'll not have to update your code with new releases of irrlicht, and if you plan so, you could release it for example as separeted addon library. Just an idea. :)
firestar
Posts: 2
Joined: Tue Nov 11, 2003 4:53 pm

Post by firestar »

i currently try to build my own set of widgets, running into problems.
First i create my own class MyGUIListbox taking a copy of the sources of CGUIListBox.
First i have some problems figuring out, how to make my own Widget visible. I was looking
for a container, to add my widget, but then
finally a had an idea. Setting the paramter IGUIElement* parent to the GUIEnvironment will add my Component to the GUIEnvironment, won't it ?

Code: Select all

IGUIEnvironment *gui = device->getGUIEnvironment();
MyListBox *listbox = new MyListBox(gui,(GUIElement*)gui,0,rect<s32>(0,0,200,400));
but when creating the instance, in the constructor of the baseclass IGUIElement, at the second line

Code: Select all

if (Parent)
   Parent->addChild(this)
i got an Exception saying:
The Value if ESP was not properly saved across a function call. This is usally a result of
calling a function declared by one calling convention with a function pointer declared with
a different convention.

what have i done wrong ? Some Compiler-Switches wrong? I'm using VC++6.0
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

firestar wrote:Setting the paramter IGUIElement* parent to the GUIEnvironment will add my Component to the GUIEnvironment, won't it ?
Just set an existing widget as parent. And if you want to place your new widget directly without a parent, you'll need to get the root Gui element, but it is not accessible yet, sorry, if forgot that. But it is already in 0.4.2 :)
firestar
Posts: 2
Joined: Tue Nov 11, 2003 4:53 pm

Post by firestar »

It worked!! Thanks for the tip!

I also have a suggestion. Making the private-Members in the ListBox-Class protected, would make programming deriving classes easier. My intention was to overload the draw-function to create a different look&feel. But the Listbox uses some private functions, that i cannot access in the derived class. So i had to copy the source. Maybe it would be a good idea, to use private declarations sparse.
Post Reply