Error when Ressources are not specified or not found

hotdot

03-12-2007 23:04:57

Clean up of code or add defensive programming : Ok i got a comment on a frustrating bug that should not appear, and only appear in a strange place if no skin is found, that is if the ressources are not specified or skins are not found there should be an ASSERT somewhere in the code to tell us, because it gives weird errors if resources are not found.

Thanks KungfooMasta

kungfoomasta

03-12-2007 23:18:57

Clean up of code or add defensive programming

I try to do both.. :P

Good point, and I think this is a simple fix! In Widget::setSkin, if the skin does not exist, I just return, but I should probably assert this, to tell the user they tried to set a skin that does not exist.

I guess the rule I should make is: If you want access to an object that doesn't exist, return NULL. If you have a function that uses an object that turns out to be NULL throw an exception, instead of silently aborting the function.

Will add this in tonight, and maybe even commit, but be warned the SVN will be changing frequently. When I finish the Render quest I'll update the SVN thread, so people will know.

hotdot

03-12-2007 23:22:57

Well i am ok to just get the svn content by the end of the week, we have to get going on the gui in the game, if any problems strikes me ill let you know :)

thanks again for your tremendous support !

kungfoomasta

04-12-2007 02:30:52

I didn't add an assert, but I check for NULL and throw an exception, like I said above. It is checked into SVN, and the demo is working for me, but I make no gaurantees!


SkinSet* ss = SkinSetManager::getSingleton().getSkinSet(skinName);
if(ss == NULL)
throw Ogre::Exception(Ogre::Exception::ERR_ITEM_NOT_FOUND,"Skin \"" + skinName + "\" does not exist! Did you forget to load it using the SkinSetManager?","Widget::setSkin");


It should be a useful message, no? :)

hotdot

04-12-2007 03:15:28

Well it could be, but the thing is i load my skin with the manager, but some dumb ass did not wrote down the paths in the resource.cfg file, so we lost some time wondering what was the curious bug when the app closed. So you have to check also when the app closes.

add : or check that skin file resources are properly loaded.

kungfoomasta

04-12-2007 03:20:26

:?: (lost)

What is it that QuickGUI should be checking when the app is closed? Its up to the user to load skins and then use them. We're just trying to remind users to load skins if they are trying to be used while not loaded. QuickGUI doesn't know what skins the user uses, it can't enforce or make a check to see what *should* be loaded. I probably missed something.. :P

hotdot

04-12-2007 03:41:49

I have an unexpected crash when the skin manager trys to delete skins that are loaded but does not have actually stuff loaded, like it trys to do something, but since the resources where not loaded it crashes, try it you'll be able to trace it.

kungfoomasta

04-12-2007 03:49:33

I didn't get the crash, but I did find a bug, and I remember talking about it a while back, but didn't know if it was my code or not.. :oops:

First off, SkinSet destructor was public, and should not be. Only SkinSetManager can destroy Skins. Also, there is no current way to remove/destroy SkinSets, except on SkinSetManager destruction. This should be added in at some point. Finally, the bug in the SkinSet constructor. The code now looks like this:


SkinSet::~SkinSet()
{
// Remove Texture for this SkinSet from Texture Manager
if(Ogre::TextureManager::getSingletonPtr()->resourceExists(mTextureName))
Ogre::TextureManager::getSingletonPtr()->remove(mTextureName);

if(Ogre::MaterialManager::getSingletonPtr()->resourceExists(mMaterialName))
Ogre::MaterialManager::getSingletonPtr()->remove(mMaterialName);
}


Also, are you using SVN? Make sure to create QuickGUI::Root (after Ogre initialization) and destroy Root (before Ogre shutdown). Also, Root is the only object able to create/destroy GUIManagers.

Sorry for your frustration. :(

kungfoomasta

04-12-2007 03:58:04

A few commits ago I accidentally commited the line:

pass->getTextureUnitState(0)->setTextureFiltering(Ogre::TFO_NONE);

In VertexBuffer::_render. Not that it will matter after I fix things, but if you do want to use latest SVN, you should comment that line. No filtering makes the text look really bad, and some of the images look pixelated (because they are not filtered, of course! :wink: )