Welcome! Log In Create A New Profile

Advanced

Need some help with an exception

Posted by SteelSLasher 
Need some help with an exception
July 05, 2009 07:37PM
My summer hols just started the other day and until my preordered special edition of Conduit arrives i thought i could work on some homebrew.

So I found my WiiXplore project file and got to work on it, the main focus right now is sorting the GUI. I downloaded libwiigui and used the template as a start on the gui.

I wanted to make a splash screen while the networking was getting set up (it only takes about 50 frames but the short splash screen makes the wii feel faster)

I resized the image for the splash screen so the sizes ares multiples of four and compiled the entire project with splash screen code in.

After making a few adjustments i got the splash screen i wanted but now it gives and exception. Using the adress to line tool in devkitppc i found nothing useful since the backtrace is for files in libogc and pointed at line 0 ?!

Since the newest thing that could cause an exception was the splash screen i guessed it was to do with that but i cant tell whats wrong

I have the function which is used to create the splash screen, I have tried to reduce memory leaks but I feel that i need to learn more about them to be able to reduce their occurences
static int Splash()
{

GuiImage Splash;
static GuiImageData * SplashImage;
SplashImage = new GuiImageData(wiixplore_png);
Splash = GuiImage(SplashImage->GetImage(), 452, 228);
Splash.SetAlignment(2,5);
Splash.SetPosition(0,0);
mainWindow->Append(&Splash);

s32 ip;
if((ip = net_init()) == -EAGAIN)
{
	GuiText init("Initialising...", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	mainWindow->Append(&init);
	Debug("1");
}
else
{
if(ip < 0) {
	Debug("2");
	GuiText init("Error while initialising... exiting", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	mainWindow->Append(&init);
	WindowPrompt("Error while initialising", "Application exiting. Please check connection settings", "Ok", FALSE);
	Debug("3");

	exit(0);
}
    debug("6");
char myIP[16];
if (if_config(myIP, NULL, NULL, true) < 0) {
	GuiText init("Error reading IP address... exiting", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	mainWindow->Append(&init);
	WindowPrompt("Error reading IP address", "Application exiting. Please check connection settings", "Ok", FALSE);
	Debug("4");
	exit(0);
}
debug("7");

mainWindow->Append(&Splash);   \\I just put these lines 
mainWindow->Append(&init);          \\in but i dont have time no to compile and test them so please consider that

return MENU_SETTINGS;
}

return SPLASH;
}
Re: Need some help with an exception
July 05, 2009 08:00PM
Did you download the latest version of libogc? Libwiigui requires it. Also, you must call HaltGui() before Append()ing, and than ResumeGui() afterwards. You also will want to use ExitRequested = 1 instead of exit(0), or even better make the splash screen a "menu" that returns an int, like the other menus in the template. Do this by declaring int menu = MENU_NONE; and then return menu; at the end of your function. Then, add this in the MainMenu() function in the while loop. Am I making any sense?



Edited 2 time(s). Last edit at 07/05/2009 08:09PM by jsmaster.
Re: Need some help with an exception
July 05, 2009 08:20PM
cool thanks for the info, the halting and resuming might explain the flickering and occasional running out of memory
Re: Need some help with an exception
July 05, 2009 09:41PM
Biggest problem is you never remove Splash or init from mainWindow

calling if_config is enough, you don't need to do if((ip = net_init()) == -EAGAIN) too

as jsmaster said, call Halt before adding/removing from your GUI, and then call resume when you're done.
Re: Need some help with an exception
July 06, 2009 11:27AM
Isnt if_config called like this:

if_config( char *local_ip, char *netmask, char *gateway,boolean use_dhcp);

But to get the local ip i need net_init() don't i?

EDIT: I just realised that if_config is just below net_init() in my code



Edited 1 time(s). Last edit at 07/06/2009 11:28AM by SteelSLasher.
Re: Need some help with an exception
July 06, 2009 11:46AM
Sorry about the double posting but i feel this needs to be in a different post

I made the edits of the haltgui and resume so the splash function looks like so:
static int Splash()
{

GuiImage Splash;
static GuiImageData * SplashImage;
SplashImage = new GuiImageData(wiixplore_png);
Splash = GuiImage(SplashImage->GetImage(), 452, 228);
Splash.SetAlignment(2,5);
Splash.SetPosition(0,0);

HaltGui();
mainWindow->Append(&Splash);
ResumeGui();

s32 ip;
if((ip = net_init()) == -EAGAIN)
{
	GuiText init("Initialising...", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	HaltGui();
	mainWindow->Append(&init);
	ResumeGui();
	Debug("1");
}
else
{
if(ip < 0) {
	Debug("2");
	GuiText init("Error while initialising... exiting", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	HaltGui();
	mainWindow->Append(&init);
	ResumeGui();
	WindowPrompt("Error while initialising", "Application exiting. Please check connection settings", "Ok", FALSE);
	Debug("3");

	ExitRequested = 1;
}
    Debug("6");
char myIP[16];
if (if_config(myIP, NULL, NULL, true) < 0) {
	GuiText init("Error reading IP address... exiting", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	HaltGui();
	mainWindow->Append(&init);
	ResumeGui();
	WindowPrompt("Error reading IP address", "Application exiting. Please check connection settings", "Ok", FALSE);
	Debug("4");
	ExitRequested = 1;
}
Debug("7");
return MENU_SETTINGS;
}

return SPLASH;
}


I havent added the if_config since its sneaked in there already
Re: Need some help with an exception
July 06, 2009 09:29PM
all of this is completely unnecessary, net_init is called by if_config already:


s32 ip;
if((ip = net_init()) == -EAGAIN)
{
	GuiText init("Initialising...", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	HaltGui();
	mainWindow->Append(&init);
	ResumeGui();
	Debug("1");
}
else
{
if(ip < 0) {
	Debug("2");
	GuiText init("Error while initialising... exiting", 16, (GXColor){0, 0, 0, 255});
	init.SetAlignment(0,3);
	init.SetPosition(5,5);
	HaltGui();
	mainWindow->Append(&init);
	ResumeGui();
	WindowPrompt("Error while initialising", "Application exiting. Please check connection settings", "Ok", FALSE);
	Debug("3");

	ExitRequested = 1;
}



Edited 1 time(s). Last edit at 07/06/2009 09:32PM by Tantric.
Re: Need some help with an exception
July 06, 2009 09:32PM
GuiImage Splash;
static GuiImageData * SplashImage;
SplashImage = new GuiImageData(wiixplore_png);
Splash = GuiImage(SplashImage->GetImage(), 452, 228);

any reason you wouldn't just do

GuiImageData SplashImage(wiixplore_png);
GuiImage Splash(&SplashImage);
Re: Need some help with an exception
July 06, 2009 09:35PM
And then at the end you need:

mainWindow->Remove(&Splash);
mainWindow->Remove(&init);

Or else your app will crash the minute it leaves that function, since those items are still in the GUI, but the memory was released when the function finished.
Re: Need some help with an exception
July 07, 2009 11:03AM
Done that now, and i put my code in a SVN on google code
[code.google.com]
Sorry, only registered users may post in this forum.

Click here to login