warnings when use event in switch?

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.
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

warnings when use event in switch?

Post by Virion »

/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:: In member function ‘virtual bool MyEventReceiver::OnEvent(irr::SEvent)’:
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_ELEMENT_FOCUS_LOST’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_ELEMENT_FOCUSED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_ELEMENT_HOVERED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_ELEMENT_LEFT’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_ELEMENT_CLOSED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_SCROLL_BAR_CHANGED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_CHECKBOX_CHANGED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_LISTBOX_CHANGED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_LISTBOX_SELECTED_AGAIN’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_FILE_CHOOSE_DIALOG_CANCELLED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_MESSAGEBOX_YES’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_MESSAGEBOX_NO’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_MESSAGEBOX_OK’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_MESSAGEBOX_CANCEL’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_EDITBOX_ENTER’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_TAB_CHANGED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_COMBO_BOX_CHANGED’ not handled in switch
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:26: warning: enumeration value ‘EGET_SPINBOX_CHANGED’ not handled in switch
:: === Build finished: 0 errors, 18 warnings ===
is this a bug or i just have to ignore the warnings?
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

by the way, when i try to add

Code: Select all

MyEventReceiver receiver;
it got this errors:
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:: In function ‘int main()’:
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:67: error: cannot declare variable ‘receiver’ to be of abstract type ‘MyEventReceiver’
/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:19: note: because the following virtual functions are pure within ‘MyEventReceiver’:
/home/leezhieng/Irrlicht/include/IEventReceiver.h:256: note: virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)
i followed exactly the tutorial at the main site...
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post by TomiZ »

You should use
virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)
not
virtual bool irr::IEventReceiver::OnEvent(irr::SEvent&)
(without "const").


If you have used for example

Code: Select all

	switch ( something )
{
	case 1 :
		foo('dadad');
		break;
	default:
		foo('sadas');
		break;
	case 2 :
		foo('dadad');
		break;
	case 3 :
		foo('dadad');
		break;
 }
Code after default (2, 3) will be ignored. Maybe you have something like this.
Last edited by TomiZ on Sat Sep 22, 2007 2:25 pm, edited 1 time in total.
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

No more error, but now, when i double click my app nothing happen..... anyone know why?
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post by TomiZ »

Use debugger to check OnEvent function.

I have added something about switch in previous post.
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

From debugger:

Code: Select all

#0 0x804c256	MyEventReceiver::OnEvent(this=0xbfc24dfc, event=@0x3) (/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:23)
#1 0x8055d37	irr::CLogger::log(this=0x82b8e08, text=0x82b8e48 "Irrlicht Engine version 1.4alpha", ll=irr::ELL_INFORMATION) (CLogger.cpp:39)
#2 0x8056a94	irr::os::Printer::log(message=0x82b8e48 "Irrlicht Engine version 1.4alpha", ll=irr::ELL_INFORMATION) (os.cpp:168)
#3 0x8055553	CIrrDeviceStub(this=0x82b8878, __vtt_parm=0x822b55c, version=0x822ab7d "1.4alpha", recv=0xbfc24dfc) (CIrrDeviceStub.cpp:31)
#4 0x80521e7	CIrrDeviceLinux(this=0x82b8878, driverType=irr::video::EDT_OPENGL, windowSize=@0xbfc24d78, bits=32, fullscreen=false, sbuffer=false, vsync=false, antiAlias=false, receiver=0xbfc24dfc, version=0x822ab7d "1.4alpha") (CIrrDeviceLinux.cpp:52)
#5 0x8052768	irr::createDeviceEx(param=@0xbfc24d74) (CIrrDeviceLinux.cpp:1324)
#6 0x804c8db	irr::createDevice(driverType=irr::video::EDT_OPENGL, windowSize=@0xbfc24df4, bits=32, fullscreen=false, stencilbuffer=false, vsync=false, res=0xbfc24dfc, version=0x822ab7d "1.4alpha") (Irrlicht.cpp:41)
#7 0x804bc88	main() (/home/leezhieng/Projects/GenetixMaterialEditor/main.cpp:68)
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

Nope I didn't use default infront of other cases.
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
Perceval
Posts: 158
Joined: Tue May 30, 2006 2:42 pm

Post by Perceval »

In my opinion, you get these warning because you've forgotten to add a 'default' case in your switch instruction.
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

thanks there is no more warnings. but still, when i launch it nothing happen.
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

warnings are just that, they're warnings alerting you to something that you could have possibly missed. Generally they mean nothing and can be ignored and will not affect how your program functions but sometimes they can be useful and point out an oversight you've made, such as not handling all the correct events in your switch. As it happens you probably don't care about those other events so you can just ignore them.
Image Image Image
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

No, I meant, no more warnings now, but then I double click my compiled app it didn't launch at all. Nothing happened.
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, your EventReceiver is wrongly initialized and core dumps on the first event sent.
Virion
Competition winner
Posts: 2149
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

ok now i copy directly from the tutorial page at the main site. it did opened a window and i can see all the gui etc. once i move my mouse/press a button it close...
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

In order to get rid of all of those warnings, just do this

Code: Select all

        default:
            break;
Right before you close your switch.. that seemed to work for me.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Virion, you still have uninitialized pointers somewhere.
Monkeycracks, I guess now every the slowest one will know it...
Post Reply