GUI Skin issues

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
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

GUI Skin issues

Post by shadowghost21 »

I created a class that implements the IGUISkin interface and I used the current CGUISkin.cpp file as an example to see how everything works. I then changed one of the colors so I would be able to tell the difference. I create a new instance and set the gui skin. I then go on to add a tab panel and boom, the guienv ref goes no nil. I'll post relevant code samples later today. But I was hoping that someone may know of the issue right off, using the download provided from the main page (IE not from the repo)
CuteAlien
Admin
Posts: 9846
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: GUI Skin issues

Post by CuteAlien »

In case you haven't already seen it, this is how reference-counting works in Irrlicht: http://irrlicht.sourceforge.net/docu/cl ... unted.html
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
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: GUI Skin issues

Post by shadowghost21 »

I understand quite well how reference counting works. I did iOS programming for 2 years Obj-C is also reference counted. You use a very similar scheme so it was a really easy concept to grasp.

If I don't use setSkin() it works fine. I also tried adding an (unnecessary) grab() I never dropped my instance of the guienv (the var named used is pretty much every example, and also created the same way) So my code looked something like this
Some of this is off the top of my head so forgive any poor API calls, the high level idea is still the same since I have neither intellisense or my code in front of me.

Code: Select all

 
IGUISkin* mySkin = new MySkin(type, driver);
//tried adding a grab(leak) there after It crashed even though I knew that it wouldn't help
guienv->setSkin(mySkin); // if you don't use this line everything works fine, unless this returns another reference to IGUIEnvironment that I didn't know about or something else that is odd. 
 
IGUITabControl* tabcontrol = guienv->addTabControl(parameters);
// die here when I go to create more elements and add them to my tab, because by this line the references some how get wiped out.
 
Up to that point there was no nil references everything looked good. I took a step over the addTab call and it bombed out on the following line while adding an element. I don't know why my guienv variable would be wiped along with my other variables. I am not getting a skin type from one of the built in types using create which is what I think you are referring to CuteAlien, I hope my code block above clears that up.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: GUI Skin issues

Post by hybrid »

Could also be a memory corruption in that case. Maybe you write over some array boundaries when setting up your skin implementation, wrecking the environment with that.
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: GUI Skin issues

Post by shadowghost21 »

hybrid wrote:Could also be a memory corruption in that case. Maybe you write over some array boundaries when setting up your skin implementation, wrecking the environment with that.
That was my thought, *sigh* C++ and the rope it gives me. I'll need to dig deep and see if I can figure out what's going on. Really all I did was copy the code from the CGUISkin.cpp file and changed a color. Is it referencing something that possibly I don't have in my media directory?
CuteAlien
Admin
Posts: 9846
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: GUI Skin issues

Post by CuteAlien »

I've tried to reproduce it with the steps you descriped: http://www.michaelzeilfelder.de/irrlich ... omskin.cpp
Does not crash. So please - post a reproducible crash or we can't help. Everything else is just guess-work and wasting everyone's time.

edit: Sorry, posted another skin-test first - corrected link above.

edit2: Please also note that you can change skin-colors without having to override the skin if that is all you want to do.

edit3: And maybe just post the exact line you changed.
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
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: GUI Skin issues

Post by shadowghost21 »

Ow Alien that sounded harsh :p Been so busy with my Old Republic early access haven't "had" any time to work :) Boggers, didn't check my code back into my repo last time I was working on it, shame on me. I'm at work and will have to wait until I get home before I can post the code up. At the very least I am glad you guys are responsive. I think it's really cool to have a dev team that responds to it's users.

After looking at that link you posted for the IGUISkin code, I know the line that I changed:

Code: Select all

Colors[EGDC_WINDOW]             = video::SColor(101,255,255,255);
I changed the color to like SColor(101,255,13,54) or something like that, just sorta made a color up so I could see if it was working. But since it never got that far I wouldn't know.

I'll get the rest of my code when I get home if you need it. I didn't change anything but that line above so I don't really understand why my GUIEnvironment would nil out. And I am not trying to waste your time consider it a philosophical discussion until I post my actual code.

Code: Select all

int main() {
 
        E_DRIVER_TYPE displayDriver = EDT_DIRECT3D9;
 
        IrrlichtDevice *device = createDevice( displayDriver, dimension2d<u32>(640, 480), 32, false, false, false, 0);
 
        if (!device)
                return 1;
 
        IVideoDriver* driver = device->getVideoDriver();
        ISceneManager* smgr = device->getSceneManager();
        IGUIEnvironment* guienv = device->getGUIEnvironment();
        IGUISkin* chaosSkin = new ChaosSkin(EGST_WINDOWS_CLASSIC, driver);
        guienv->setSkin(chaosSkin);
        IGUIWindow* win = guienv->addWindow(rect<s32>(0,0,400,400));
        IGUITabControl* tabcontrol = guienv->addTabControl(rect<s32>(25,20,350,350),win); // Dies after this line/on this line, the debugger moves the program counter back to this line for some reason and then guienv is nil
 
        IGUITab* resourceTab = tabcontrol->addTab(L"Resources",kResourcesTab);
 
That is pretty damn close to what I have for the code that I have at home. The only thing I can't get right now is the actual implementation of ChaosSkin, but like I already said I copy pasted the CGUISkin.cpp from the source folder and copied the contents of the header into my own. There was no funny business and I didn't change anything but the color of the 3d window. I am trying to make it very clear that I may be doing something wrong or I didn't copy over any of the resources it's trying to use (if it had any) But that doesn't explain why it would totally crap itself.

And for your edit 2 CuteAlien, I was just testing with a color. I had many more things in mind than changing just the color. This was a proof of concept that I was starting to prototype.

I'll edit in copy paste job of ChaosSkin.h and ChaosSkin.cpp tonight when I get home.
CuteAlien
Admin
Posts: 9846
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: GUI Skin issues

Post by CuteAlien »

Sorry if it sounded harsh. But having 2 crashreports (gui-editor the other) from you in one evening which both turned out not to be reproducible... lets just say that is a little frustrating. So just - please always try giving enough information so people on the forum can actually reproduce it when you report crashes. Not the least because very often when people work on making it reproducible they suddenly realize the real problem is somewhere else than they originally expected ;-)
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
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: GUI Skin issues

Post by shadowghost21 »

Well the gui editor crash I have no idea why no one else can get it to crash, I'll update from subversion and rebuild again. I didn't do anything but click the go button on that one lol. The old republic go in my way this weekend :) so I didn't get that code pasted. I really need to get that checked in my repo. All I have been able to think about is TOR. Thanks for all the help CuteAlien, I'll see if I can get exact steps to reproduce on my other thread after I recompile everything. I need to wait for my DirectX sdk to finish downloading here at work.
Post Reply