Setup crash @isImageFile

Qbound

16-09-2007 22:54:05

Hi,

first of all... from all the screens and the code... this gui rocks :) i have tried many gui's and coded some by my self...

But i have a problem at the beginning of the initialisation.

What is done.

Ogre is well and correct initalisized
- Root -OK
- ViewPort -OK
- Camera -OK
- SceneMGR -OK

then i want to setup the GUI. I use the current SVN Version wich compiles correct. (the Demo didnt work because of the wired resource setup...) i spend only 5-10 minutes to get it run...

so back:
m_pGUIManager = new GUIManager( m_pViewPort ); m_pGUIManager->setSceneManager( m_pSceneMgr );

the viewport and the scenemgr are 100%ok and proofen.
the resources are set to the correct path.

Now the problem.
when the GUIManager tries to create the MouseCursor it crashes. I step through the code and the program crashs at [quickguiutility.cpp] in the method isImageFile() at the line Ogre::StringUtil::toLowerCase(extension);
In extension is at that moment ('png') with the length of 3 which should be ok.
This means to me that the file was found and it should work.. but the program quits imediatly with out a exception or anything else...

i hope that some can help me..

cu
Qbound

kungfoomasta

17-09-2007 00:36:09

Thanks for the comments. It will get plenty better with the next 2 releases. :wink:

Strange a crash would occur there.

So this is the relevant code..


bool Utility::isImageFile(const Ogre::String& fileName)
{
Ogre::String::size_type index = fileName.find_last_of('.');
if( (index != Ogre::String::npos) || (index = fileName.length() - 1) )
{
Ogre::String extension = fileName.substr(index + 1);
Ogre::StringUtil::toLowerCase(extension);


Basically the function just checks if the file is of type image. It doesn't necessarily mean it exists on disk. There is a function I made called "textureExistsOnDisk" which makes use of this isImageFile function (don't remember if this is in SVN):


bool Utility::textureExistsOnDisk(const Ogre::String& textureName)
{
if(textureName == "")
return false;

if(!isImageFile(textureName))
return false;

Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr();

Ogre::StringVector resourceGroups = rgm->getResourceGroups();
Ogre::StringVector::iterator it;
for( it = resourceGroups.begin(); it != resourceGroups.end(); ++it )
{
if(rgm->resourceExists((*it),textureName))
return true;
}

return false;
}


What is the call stack on crash? I can't see how the "toLowerCase" function crashes the app.. :?

kungfoomasta

17-09-2007 00:38:38

I just noticed something important, not sure if it's related.

Make sure the header for the Utility class looks like the following:

class _QuickGUIExport Utility

The class was not being included in the DLL! :oops:

I will add this into SVN in my next commit. I've just finished getting scroll functionality, and I need to clean up some stuff and fix the List widget. So I'm not sure when I will commit my code.. somewhere between this evening and 2 days. :)

Zini

17-09-2007 08:05:26

This line is totally bogus:


if( (index != Ogre::String::npos) || (index = fileName.length() - 1) )


The expression would be always true for any fileName not of length 1. I guess you meant == instead of =. But even then the part right of the || doesn't make any sense.

Qbound

17-09-2007 12:16:23

You are right. it dosen't make sense to me too.

i have fixed the dll export in the header. and exchanged some lines of code to this one right now:

bool Utility::isImageFile(const Ogre::String& fileName)
{
Ogre::String::size_type index = fileName.find_last_of('.');
if( index != Ogre::String::npos )
{
Ogre::String extension = fileName.substr(index + 1);
Ogre::StringUtil::toLowerCase(extension);
Ogre::StringVector supportedImageCodecs(Ogre::Codec::getExtensions());

return (std::find(supportedImageCodecs.begin(),supportedImageCodecs.end(),extension) != supportedImageCodecs.end());
}

return false;
}


but the problem is already existing and i dont think that there is a problem with the validation of the extension.
My problem is that if the extension shall be converted to lowercase in the line
Ogre::StringUtil::toLowerCase(extension);
the program quits imediatly... if i uncomment (//ogre::) the line then i got trouble in the return line....

I use the Ogre 1.4.3 but i dont believe that this is the problem...
any hints...?

Zini

17-09-2007 12:56:39

Ogre::StringUtil::toLowerCase can not fail (unless the string argument or the whole heap is corrupted). Either some other part of QuickGUI or your own code is messing things up badly (assuming it is not some DLL-weirdness). Impossible to give any more hints, unless you can provide more information (log files, call stack, relevant parts of your own code, ...).

Qbound

17-09-2007 14:33:32

hmm ok i first check if my memory is ok.. (heap) in the past days i hunted some memoryleaks with my memorymanager and now they are killed and the memory should be clear... but who knows..
thanks for you tipps. :)

Qbound

17-09-2007 15:50:06

i created a small and simple ogre app and quickgui crashes at the same positions...

Here is my intialization code

// Create the RenderDevice Root
m_pRoot = new Root( m_strPlugins, m_strCFG, m_strLOG );

// Log
LogManager::getSingletonPtr()->logMessage( "-0- Init Plugins --" );

// Init the RenderDevice
#if defined(_DEBUG)
m_pRoot->loadPlugin("Plugin_ParticleFX_d");
m_pRoot->loadPlugin("RenderSystem_Direct3D9_d");
m_pRoot->loadPlugin("Plugin_OctreeSceneManager_d");
#else
m_pRoot->loadPlugin("Plugin_ParticleFX.dll");
m_pRoot->loadPlugin("RenderSystem_Direct3D9");
m_pRoot->loadPlugin("Plugin_OctreeSceneManager");
#endif

// ResourceGroupManager setzen
m_pResMgr = ResourceGroupManager::getSingletonPtr();

// Log
LogManager::getSingletonPtr()->logMessage( "-1- Init A Resourcen --" );

// Resourcen einladen
OnInit_A_Resource();

// Configuration
if( !OnInit_B_Config() )
{
// Show Configdialog
if( !m_pRoot->showConfigDialog() )
{
// Log
LogManager::getSingletonPtr()->logMessage( "- User request Shutdown -" );

// Beenden
PostQuitMessage(0);

// und wech
return false;
}
}

// Soll ein Fenster erstellt werden?
if( !m_bFullScreen )
{
// Fenster erstellen
CreateMainWindow();

// Init und RenderWindow holen
m_pRoot->initialise( false, "NightFist" );
NameValuePairList misc;
misc["externalWindowHandle"] = StringConverter::toString( (size_t)m_hWnd );
m_pRenderWindow = m_pRoot->createRenderWindow( "NightFist", m_uiWindowWidth, m_uiWindowHeight, false, &misc );
} else {

// Fullscreen

// Init und RenderWindow holen
m_pRoot->initialise( false, "NightFist" );
m_pRenderWindow = m_pRoot->createRenderWindow( "NightFist", m_uiWindowWidth, m_uiWindowHeight, true );

// Das Windowhandle setzen
m_pRenderWindow->getCustomAttribute("WINDOW", &m_hWnd);
}

// Das Window Zeigen
ShowWindow( m_hWnd, SW_SHOW );

// Log
LogManager::getSingletonPtr()->logMessage( "-2- Init C SceneManager --" );

// Scene Manager
if( !OnInit_C_SceneMgr() )
{
// SceneManager erstellen
m_pSceneMgr = m_pRoot->createSceneManager( ST_GENERIC, "MySceneManager" );
}

// RootNode setzen
m_pRootNode = m_pSceneMgr->getRootSceneNode();

// Ray Scene Query erstellen
m_pRaySceneQuery = m_pSceneMgr->createRayQuery( Ray() );

// Log
LogManager::getSingletonPtr()->logMessage( "-3- Init D Camera --" );

// Kamera setzen
if( !OnInit_D_Camera() )
{
// Kamera erstellen
m_pCamera = new COGRE_CAMERA( "MainCamera", m_pSceneMgr );
}

//Log
LogManager::getSingletonPtr()->logMessage( "-4- Init ViewPort --" );

// Viewport erstellen
m_pViewPort = m_pRenderWindow->addViewport( m_pCamera->GetOgreCam() );
m_pViewPort->setBackgroundColour( ColourValue( 0.0f, 0.0f, 0.0f ) );
m_pCamera->SetAspectRatio( 1.33333f );
m_pRoot->getRenderSystem()->_setViewport( m_pViewPort );

//Log
LogManager::getSingletonPtr()->logMessage( "-5- Init ResourceManager --" );

// Alle Resourcen laden
m_pResMgr->initialiseAllResourceGroups();

// Create the GUIManager from SVN
//m_pGUIManager = new QuickGUI::GUIManager( m_pViewPort );
//m_pGUIManager->setSceneManager( m_pSceneMgr );

// Create the GUIManager from 0.9.6b
m_pGUIManager = GUIManager::getSingletonPtr();
m_pGUIManager->setup( m_pRenderWindow->getWidth(), m_pRenderWindow->getHeight() );


i moved the GUIinit to the earliest position possible...

the SVN Version crashes at the line 'toLowerCase'
and the 096b at the position where the Sheet is created in the line if( rmi.hasMoreElements) the pointer to the rmi seem to be corrupt...
Sheet::Sheet(const Ogre::String& name, const Ogre::String& texture) :
Panel(name,Rect(0,0,1,1),QGUI_GMM_RELATIVE,QGUI_GMM_RELATIVE,texture,NULL,NULL),
mDefaultTextColor(Ogre::ColourValue::White),
mDefaultSkin("qgui"),
mAutoNameWindowCounter(0)
{
mWidgetType = Widget::TYPE_SHEET;
mRenderObject->setLayer(RenderObject::LAYER_CHILD);

Ogre::FontManager* fm = Ogre::FontManager::getSingletonPtr();
Ogre::ResourceManager::ResourceMapIterator rmi = fm->getResourceIterator();
if(rmi.hasMoreElements())
mDefaultFont = rmi.getNext()->getName();
else
Ogre::Exception(1,"No fonts have been defined!","Sheet::Sheet");
}

This is my log


16:52:51: Creating resource group General
16:52:51: Creating resource group Internal
16:52:51: Creating resource group Autodetect
16:52:51: SceneManagerFactory for type 'DefaultSceneManager' registered.
16:52:51: Registering ResourceManager for type Material
16:52:51: Registering ResourceManager for type Mesh
16:52:51: Registering ResourceManager for type Skeleton
16:52:51: MovableObjectFactory for type 'ParticleSystem' registered.
16:52:51: OverlayElementFactory for type Panel registered.
16:52:51: OverlayElementFactory for type BorderPanel registered.
16:52:51: OverlayElementFactory for type TextArea registered.
16:52:51: Registering ResourceManager for type Font
16:52:51: ArchiveFactory for archive type FileSystem registered.
16:52:51: ArchiveFactory for archive type Zip registered.
16:52:51: FreeImage version: 3.9.2
16:52:51: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
16:52:51: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi
16:52:51: DDS codec registering
16:52:51: Registering ResourceManager for type HighLevelGpuProgram
16:52:51: Registering ResourceManager for type Compositor
16:52:51: MovableObjectFactory for type 'Entity' registered.
16:52:51: MovableObjectFactory for type 'Light' registered.
16:52:51: MovableObjectFactory for type 'BillboardSet' registered.
16:52:51: MovableObjectFactory for type 'ManualObject' registered.
16:52:51: MovableObjectFactory for type 'BillboardChain' registered.
16:52:51: MovableObjectFactory for type 'RibbonTrail' registered.
16:52:51: *-*-* OGRE Initialising
16:52:51: *-*-* Version 1.4.3 (Eihort)
16:52:51: -0- Init Plugins --
16:52:51: Loading library Plugin_ParticleFX_d
16:52:51: Installing plugin: ParticleFX
16:52:51: Particle Emitter Type 'Point' registered
16:52:51: Particle Emitter Type 'Box' registered
16:52:51: Particle Emitter Type 'Ellipsoid' registered
16:52:51: Particle Emitter Type 'Cylinder' registered
16:52:51: Particle Emitter Type 'Ring' registered
16:52:51: Particle Emitter Type 'HollowEllipsoid' registered
16:52:51: Particle Affector Type 'LinearForce' registered
16:52:51: Particle Affector Type 'ColourFader' registered
16:52:51: Particle Affector Type 'ColourFader2' registered
16:52:51: Particle Affector Type 'ColourImage' registered
16:52:51: Particle Affector Type 'ColourInterpolator' registered
16:52:51: Particle Affector Type 'Scaler' registered
16:52:51: Particle Affector Type 'Rotator' registered
16:52:51: Particle Affector Type 'DirectionRandomiser' registered
16:52:51: Particle Affector Type 'DeflectorPlane' registered
16:52:51: Plugin successfully installed
16:52:51: Loading library RenderSystem_Direct3D9_d
16:52:51: Installing plugin: D3D9 RenderSystem
16:52:51: D3D9 : Direct3D9 Rendering Subsystem created.
16:52:51: D3D9: Driver Detection Starts
16:52:51: D3D9: Driver Detection Ends
16:52:51: Plugin successfully installed
16:52:51: Loading library Plugin_OctreeSceneManager_d
16:52:51: Installing plugin: Octree & Terrain Scene Manager
16:52:51: Plugin successfully installed
16:52:51: -1- Init A Resourcen --
16:52:51: Added resource location 'DATA/GUI' of type 'FileSystem' to resource group 'General'
16:52:51: Added resource location 'DATA/GUI/QGUI/' of type 'FileSystem' to resource group 'General'
16:52:51: Added resource location 'DATA/NATURE/SKYDOME/' of type 'FileSystem' to resource group 'General'
16:52:51: Added resource location 'DATA/MODELS/AVATAR/' of type 'FileSystem' to resource group 'General'
16:52:51: Added resource location 'DATA/MODELS/SYSTEM/' of type 'FileSystem' to resource group 'General'
16:52:51: Added resource location 'DATA/MODELS/NPC/ANIMATION/' of type 'FileSystem' to resource group 'General'
16:52:51: Added resource location 'DATA/NATURE/TERRAIN/GREEN/' of type 'FileSystem' to resource group 'General'
16:52:51: D3D9 : RenderSystem Option: VSync = No
16:52:51: D3D9 : RenderSystem Option: Allow NVPerfHUD = No
16:52:51: D3D9 : RenderSystem Option: Floating-point mode = Fastest
16:52:51: D3D9 : RenderSystem Option: Anti aliasing = None
16:52:51: D3D9 : RenderSystem Option: Full Screen = No
16:52:51: D3D9 : RenderSystem Option: Video Mode = 800 x 600 @ 32-bit colour
16:52:51: CPU Identifier & Features
16:52:51: -------------------------
16:52:51: * CPU ID: GenuineIntel: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
16:52:51: * SSE: yes
16:52:51: * SSE2: yes
16:52:51: * SSE3: yes
16:52:51: * MMX: yes
16:52:51: * MMXEXT: yes
16:52:51: * 3DNOW: no
16:52:51: * 3DNOWEXT: no
16:52:51: * CMOV: yes
16:52:51: * TSC: yes
16:52:51: * FPU: yes
16:52:51: * PRO: yes
16:52:51: * HT: no
16:52:51: -------------------------
16:52:51: D3D9 : Subsystem Initialising
16:52:51: ***************************************
16:52:51: *** D3D9 : Subsystem Initialised OK ***
16:52:51: ***************************************
16:52:51: D3D9RenderSystem::createRenderWindow "NightFist", 800x600 windowed miscParams: externalWindowHandle=1117680
16:52:51: D3D9 : Created D3D9 Rendering Window 'NightFist' : 792x566, 32bpp
16:52:51: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem.
16:52:51: Registering ResourceManager for type Texture
16:52:51: Registering ResourceManager for type GpuProgram
16:52:51: Multiple render targets with independent bit depths supported
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT16_RGB
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT16_RGBA
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT32_RGB
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT32_RGBA
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT16_R
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT32_R
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT16_GR
16:52:51: D3D9: Vertex texture format supported - PF_FLOAT32_GR
16:52:51: RenderSystem capabilities
16:52:51: -------------------------
16:52:51: * Hardware generation of mipmaps: yes
16:52:51: * Texture blending: yes
16:52:51: * Anisotropic texture filtering: yes
16:52:51: * Dot product texture operation: yes
16:52:51: * Cube mapping: yes
16:52:51: * Hardware stencil buffer: yes
16:52:51: - Stencil depth: 8
16:52:51: - Two sided stencil support: yes
16:52:51: - Wrap stencil values: yes
16:52:51: * Hardware vertex / index buffers: yes
16:52:51: * Vertex programs: yes
16:52:51: - Max vertex program version: vs_3_0
16:52:51: * Fragment programs: yes
16:52:51: - Max fragment program version: ps_3_0
16:52:51: * Texture Compression: yes
16:52:51: - DXT: yes
16:52:51: - VTC: no
16:52:51: * Scissor Rectangle: yes
16:52:51: * Hardware Occlusion Query: yes
16:52:51: * User clip planes: yes
16:52:51: * VET_UBYTE4 vertex element type: yes
16:52:51: * Infinite far plane projection: yes
16:52:51: * Hardware render-to-texture: yes
16:52:51: * Floating point textures: yes
16:52:51: * Non-power-of-two textures: yes
16:52:51: * Volume textures: yes
16:52:51: * Multiple Render Targets: 4
16:52:51: * Point Sprites: yes
16:52:51: * Extended point parameters: yes
16:52:51: * Max Point Size: 8192
16:52:51: * Vertex texture fetch: yes
16:52:51: - Max vertex textures: 4
16:52:51: - Vertex textures shared: no
16:52:51: ResourceBackgroundQueue - threading disabled
16:52:51: Particle Renderer Type 'billboard' registered
16:52:51: SceneManagerFactory for type 'OctreeSceneManager' registered.
16:52:51: SceneManagerFactory for type 'TerrainSceneManager' registered.
16:52:51: -2- Init C SceneManager --
16:52:51: TerrainSceneManager: Registered a new PageSource for type Heightmap
16:52:51: -3- Init D Camera --
16:52:51: -4- Init ViewPort --
16:52:51: Creating viewport on target 'NightFist', rendering from camera 'MainCamera', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
16:52:51: Viewport for camera 'MainCamera', actual dimensions L: 0 T: 0 W: 792 H: 566
16:52:51: -5- Init ResourceManager --
16:52:51: Parsing scripts for resource group Autodetect
16:52:51: Finished parsing scripts for resource group Autodetect
16:52:51: Parsing scripts for resource group General
16:52:51: Parsing script SkyDome.material
16:52:51: Parsing script char1.material
16:52:51: Parsing script Example.material
16:52:51: Parsing script Ninja.material
16:52:51: Parsing script Box.material
16:52:51: Parsing script DEFAULT.material
16:52:51: Parsing script scoob.material
16:52:51: Parsing script tie_wolf_01.material
16:52:51: Parsing script font.fontdef
16:52:51: Finished parsing scripts for resource group General
16:52:51: Parsing scripts for resource group Internal
16:52:51: Finished parsing scripts for resource group Internal

kungfoomasta

17-09-2007 16:28:56

If you comment out all creation of GUIManager, does the app run? Are you debugging in release or debug mode? (if not debug, try stepping through in debug) Are you able to compile and run the demo on your system?

Qbound

17-09-2007 17:36:00

the app is running well and is currently compiled in debug mode like any other things... One thing is different. The GUI is compiled in VC8 and the Game is Compiled in VC7.1...
The demo app didn't work because the Pathes are not correct.

At the moment the app does nothing fancy if i uncomment the GUI then i ll see a skydome nothing more...

kungfoomasta

17-09-2007 19:49:46

I don't know if there would be a problem mixing VC7.1 with VC8, but can you compile your game in VC8 just to eliminate the possibility?

The demo app didn't work because the Pathes are not correct.

Do you mean resource paths? All you would need to do is make sure the skin files are declared as resources in Ogre. (If you use resources.cfg add their location in here, or add the folder location via code)

Our first action should be getting you to run the demo. When that works, we can work on the integration with your app.

Regarding the check within the "if" in the earlier posts.. I updated my code to use your check. Sometimes its hard to think clearly after a long days work, so stupid mistakes may occur. But hopefully not too many, and most importantly, nothing I can't fix! :)

Qbound

17-09-2007 22:29:05

Hi...

thanks for your support...

now the app and the demo is running.

What i have done...

i deleted the complete QuickGUI SVN Directory
Uninstalled the OGRESDK (VC2003)
Downloaded the OGRE 1.4.4 (VC2005)
Downloaded the current SVN
made the changes to isImageFile
made some changes to some of the directory paths (Projectsettings)
converted my App to VC2005

Jepp... more than 20 hours of spare time over the last 5 days.... and the problem was so simple...

cu
Oliver

kungfoomasta

17-09-2007 22:40:19

Sorry you had so much trouble getting it working! :(

Make sure to let me know of any other problems or suggestions you have!

Next version I will more openly ask for user requested features, but currently I still have a lot of big requests I'm working on finishing at the moment. Don't let that prevent you from providing feedback, it's most useful to me. :)