Gui bugs [not 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
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Gui bugs [not a bug]

Post by Yustme »

Hi,

I extended an event receive class which used to handle all keyboard and mouse events, with gui events.

I am talking about these 2 events:

Code: Select all

EGET_ELEMENT_FOCUSED
GET_ELEMENT_FOCUS_LOST
If i press enter in an editable box, EGET_ELEMENT_FOCUSED will make my app crash showing me this error message:

Unhandled exception at 0x00412609 in HandlingGuiEvents.exe: 0xC0000005: Access violation reading location 0x60500050.

And pointing to this line:

Code: Select all

callerID = event.GUIEvent.Caller->getID();

In this peace of code:

Code: Select all

case EGET_ELEMENT_FOCUSED:
{
	callerID = event.GUIEvent.Caller->getID();
	elementStatus[EGET_ELEMENT_FOCUSED] = TRUE;
					
	break;
}

I know "callerID" is not causing this error because i have tested it like this:

Code: Select all

if(event.GUIEvent.Caller->getID() != 0)
  callerID = event.GUIEvent.Caller->getID();

It crashed again pointing this time to the if statement line.

This is the callstack:

> HandlingGuiEvents.exe!CIrrEventReceiver::OnEvent(const irr::SEvent & event={...}) Line 300 + 0x12 bytes C++
Irrlicht.dll!100e02db()
[Frames below may be incorrect and/or missing, no symbols loaded for Irrlicht.dll]
Irrlicht.dll!100e09bf()
ntdll.dll!7c913212()
ntdll.dll!7c913281()
nvoglnt.dll!69725132()
ntdll.dll!7c926abe()
ntdll.dll!7c96cde9()
user32.dll!7e418724()
user32.dll!7e418806()
user32.dll!7e41c623()
user32.dll!7e41c649()
opengl32.dll!5ed2699b()
user32.dll!7e41ead2()
user32.dll!7e418724()
user32.dll!7e418806()
user32.dll!7e4189bd()
user32.dll!7e41c950()
user32.dll!7e41ca4b()
user32.dll!7e4196b7()
Irrlicht.dll!100e147d()
HandlingGuiEvents.exe!main(int argc=1, char * * argv=0x003a5fc0) Line 106 + 0x14 bytes C++
HandlingGuiEvents.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C
HandlingGuiEvents.exe!mainCRTStartup() Line 414 C
kernel32.dll!7c816ff7()

And EGET_ELEMENT_FOCUS_LOST makes my app crash (sometimes) immediately and pointing to the same line:

Code: Select all

callerID = event.GUIEvent.Caller->getID();

By the way, this event:

Code: Select all

EGET_EDITBOX_ENTER

Made my app crash a few times too, even though i didn't had an editable box at that time yet.

Now that i do have a few editable boxes, it doesn't make it crash anymore.

I have tried fixing the bugs but i ended up overwriting the "messed up" files again.

Are these bugs or am i doing something wrong?
Last edited by Yustme on Tue Jan 29, 2008 1:29 pm, edited 1 time in total.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Did you properly check for the even being a GUI event? nPlease show the full code of the event receiver.
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Post by Yustme »

hybrid wrote:Did you properly check for the even being a GUI event? nPlease show the full code of the event receiver.

Hi hybrid,

That's the problem. I don't want to handle that event. So i didn't check if that event has been fired or not.

It fires itself and making my app crash.

I posted the event receiver class in this thread:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24508

And this is the main.cpp:

Code: Select all

#include <irrlicht.h>
#include "CIrrEventReceiver.h"

// irrlicht namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

// standard namespace
using namespace std;

int main(int argc, char **argv)
{
	CIrrEventReceiver rv;
	IrrlichtDevice* device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 32, false, true, true, &rv);
	IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	
	// set font for
	IGUISkin* skin = guienv->getSkin();
	IGUIFont* menuFont = guienv->getFont("data/fontlucida.png");
	
	// set font for the menu.
	skin->setFont(menuFont);
	
	// set font for the tooltip.
	skin->setFont(guienv->getBuiltInFont(), EGDF_TOOLTIP);
	
	// create the window where we want to put our controls on.
	IGUIWindow* window = guienv->addWindow(rect<s32>(position2di(80, 30),dimension2di(600, 550)),false,L"Menu",0,101);
	
	// add statictext above scrollbar.
	guienv->addStaticText(L"Transparent Control:", rect<s32>(position2di(50,50),dimension2di(200,20)), true, false, window);
	
	//
	// create a horizontal scrollbar
	//
	IGUIScrollBar* scrollbar1 = guienv->addScrollBar(true, rect<s32>(position2di(50,75),dimension2di(200,20)), window, 102);
	
	// set the maximum value of the scrollbar to 255.
	scrollbar1->setMax(255);

	// set scrollbar position to alpha value of an arbitrary element
	scrollbar1->setPos(guienv->getSkin()->getColor(EGDC_WINDOW).getAlpha());

	//
	// create a few buttons.
	//
	IGUIButton* button1 = guienv->addButton(rect<s32>(position2di(50,105),dimension2di(200,30)), 
			window,104, L"Button 1",L"Button 1");
	
	//
	// create a few editableboxes:
	//
	IGUIEditBox* editbox1 = guienv->addEditBox(L"Editable Box 1", rect<s32>(position2di(300,105),dimension2di(200,20)), true, window, 107);
	
	//
	// create a few checkboxex.
	//
	IGUICheckBox* checkbox1 = guienv->addCheckBox(false, rect<s32>(position2di(265,50),dimension2di(20,20)), window, 110);

	while(device->run())
	{
		if (device->isWindowActive()) 
		{
			// end process events
			rv.endEventProcess();
			
			driver->beginScene(true, true, video::SColor(0,0,0,0)); 
			guienv->drawAll();
			driver->endScene();
			
			
			// handling editable boxes event:
			if(rv.getEventCallerByID() == 107 && rv.getEventCallerByElement(EGET_EDITBOX_ENTER))
				cout << "you have pressed the enter button in the editable box 1" << endl;

			// start processing the events of keyboard/mouse button presses.
			rv.startEventProcess();
		}
	}
	
	device->drop();

	return 0;
}

If you want to see EGET_EDITBOX_ENTER making the app crash too, just comment all the editable boxes and then run the app. It usually crashes immediately.

So if that's not the case, restart the app again.
Last edited by Yustme on Tue Jan 29, 2008 11:01 am, edited 1 time in total.
CuteAlien
Admin
Posts: 10062
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Can't you reduce it to the minimum needed to reproduce the crash? I can nearly guess that for example a skybox has nothing to do with the crash in the eventreceiver. But who knows. You have the best chances to know which parts of the applications are necessary and which not - everybody else will first have to read & understand your application and then reduce it to the minimum just to find out where to start looking. And the more code you post, the less fun this is. You post two large blocks of code, distributed in two threads! So please... reduce it to the important parts.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Frosty Topaz
Posts: 107
Joined: Sat Nov 04, 2006 9:42 pm

Post by Frosty Topaz »

If you keep seeing errors on a line that has -> I'd make sure the pointer's not null. Bear in mind I've not looked in depth at your code, but it seems this might be it from the error code you posted.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Post by Yustme »

Hi,

The code has been reduced.

You're gonna have to remove the editable box declared in front of the while loop and in the while loop where its being used in order to get this event:

EGET_EDITBOX_ENTER

Crash the app. It happens immediately, if not restart the app.

For this event:

EGET_ELEMENT_FOCUSED

Just press the enter button on any gui element on the window and it will make it crash.

This event:

EGET_ELEMENT_FOCUS_LOST

Makes the app crash randomly. Play with the scrollbar then leave it and it may crash.

This function:

event.GUIEvent.Caller->getID()

Is causing the "access violation reading location" error.

Although it did passed the ID to "callerID", it's still crashing.

I know this because i hovered my mouse over the variable when it crashed and pointing to that line.

About the CIrrEventReceiver class, what should i do? Paste it here as well?
CuteAlien
Admin
Posts: 10062
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Yustme wrote: About the CIrrEventReceiver class, what should i do? Paste it here as well?
The idea is usually to reduce the code for bugreports until you have only that part left which is needed to reproduce the bug. Quite often while doing so you find the bug anyway. So don't paste it, but reduce it to the minimum needed to reproduce the bug. Which should according to your description probably be an eventreceiver with nothing at all beside the cases for the two events where it crashes.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Post by Yustme »

Hi CuteAlien,

Why didn't you said that the first time :P

I'll reduce that class as well and i'll let you know if that still makes the app crash.

Thanks!
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Post by Yustme »

Hi,

I have reduced the eventreceiver class to only gui events and functions. My app didn't crash anymore.

Then i put everything back and went through the code and commented the entire switch case except for the gui events.

Just to be clear, i commented these cases:

Code: Select all

case EET_KEY_INPUT_EVENT:
case EET_MOUSE_INPUT_EVENT:

Then i found out that it doesn't crash my app.

And then i moved the gui event case:

Code: Select all

case EET_GUI_EVENT:

At the top and uncommented the keyboard and mouse input cases:

Code: Select all

case EET_KEY_INPUT_EVENT:
case EET_MOUSE_INPUT_EVENT:

Just to be sure that the EET_KEY_INPUT_EVENT is not causing the app to crash when i put the EET_GUI_EVENT under it, i have tried that option too.

But the app crashed in this case too.

Conclustion: it has to do with the order i had the event cases in the switch statement.

Starting with the EET_GUI_EVENT in the switch statement fixed the bug :D
CuteAlien
Admin
Posts: 10062
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

If re-ordering a case-switch has unexpected results a red colored label should start to blink with the text: "search for the missing break" :-)

And a short look on your OnEvent does indeed show that "case EET_KEY_INPUT_EVENT:" is missing the final break.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

You were probably missing a break statement in your switch block, meaning it's a bug in your code not in Irrlicht.
It's really not very helpful making everyone spend time debugging Irrlicht when the problem is probably in your code. In future try the beginners help forum first and only post here if it turns out to be a bug in Irrlicht. If it is a bug in Irrlicht then post a simple demonstration in here like CuteAlien said.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Yustme
Posts: 107
Joined: Sat Dec 01, 2007 10:50 pm

Post by Yustme »

Hi,

You guys where right. It missed 2 breaks between some cases.

@bitplane,

I've learned my lesson. I'll never post a bug report again :wink:

Thanks for the help!
Post Reply