CheckBox problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

CheckBox problem

Post by ent1ty »

I'm having a problem with ->isChecked method of this class. My game crashes when doing this

Code: Select all

bool enableDynamicShadows= set_dyns->isChecked();
Is somehing wrong with it?
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: CheckBox problem

Post by randomMesh »

Looks like a null pointer exception.
Do something like this:

Code: Select all

bool enableDynamicShadows = false;
if (set_dyns)
	enableDynamicShadows= set_dyns->isChecked();
else
	printf("OMG my pointer is invalid!\n");
And watch the console for that message.
"Whoops..."
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

The pointer is good, set_dyns->setChecked() etc. runs fine. Only isChecked() doesn't work.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Are you sure the crash happens in that line? What does the debugger tell?
"Whoops..."
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

Yes, it happens at that line. Debuger: Unhandled exception at 0x00406434 in game.exe: 0xC0000005: Access violation reading location 0x00000000.
Lambda
Posts: 126
Joined: Wed Feb 27, 2008 3:00 pm
Location: Spain, Huelva
Contact:

Post by Lambda »

ent1ty wrote:Yes, it happens at that line. Debuger: Unhandled exception at 0x00406434 in game.exe: 0xC0000005: Access violation reading location 0x00000000.
It seems to be a null pointer :)
Image
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

Could it be the problem that IGUICheckBox* set_dyns= 0; is global but set_dyns= env->addCheckBox() is inside of a function and isChecked in another function? [/code]
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

OK, so I fixed this. But I have one more question: defaultly, when I click X in the top right corner, the window is destroyed. How can i change this to only set the window invisible?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You can catch EGET_ELEMENT_CLOSED for the window, call setVisible(false) on the window and then return true in the event-receiver to prevent the event from being passed on.
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
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

I already solved it with window->getCloseButton()->setVisible(false); and then making my own "close"(make invisible) button. But that is also a good idea, thanks.
Post Reply