Page 1 of 1

problem of destroyAllImagesets method

Posted: Thu Jan 17, 2008 16:36
by chendot
I got a StaticImage to show the map picture, and the picture is changed accroding to a map list. So I wrote a function for subscribing the list Selected event. Each time the user selects a map from the list, the staticImage would show the relevant map picture.

I wanted to implement map picture changing as below.

Code: Select all

bool OnSceneListSelectedClicked(const CEGUI::EventArgs& e)
{
    ...
    ImagesetManager::getSingleton().destroyAllImagesets();
    ImagesetManager::getSingleton().createImagesetFromImageFile("map", mapfile);
    WindowManager::getSingleton().getWindow("SceneSImg")->setProperty("Image", "set:map image:full_image");
    ...
}


but it cause a error from "destroyAllImagesets()" function. It seems that CEGUI::System::getSingleton().renderGUI() get a NULL Image pointer error after doing that.

Any help please....

Posted: Fri Jan 18, 2008 09:36
by CrazyEddie
If any other part of the UI is using imagery your call to destoryAllImagesets is destroying that imagery so when it tries to draw something (static image frame?) the imagery no longer exists.

Don't call destroyAllImagesets - be more selective in what you destroy :)

CE.

Posted: Fri Jan 18, 2008 17:26
by chendot
CrazyEddie wrote:If any other part of the UI is using imagery your call to destoryAllImagesets is destroying that imagery so when it tries to draw something (static image frame?) the imagery no longer exists.

Don't call destroyAllImagesets - be more selective in what you destroy :)

CE.


Thank you, CrazyEddie,
I've changed my code as below, and it works.

Code: Select all

if (ImagesetManager::getSingleton().isImagesetPresent("map"))
      {
         Imageset* imgset = ImagesetManager::getSingleton().getImageset("map");
         ImagesetManager::getSingleton().destroyImageset(imgset);
      }
      ImagesetManager::getSingleton().createImagesetFromImageFile("map", mapView);
      WindowManager::getSingleton().getWindow("SceneSImg")->setProperty("Image", "set:map image:full_image");

but I still feel a little confounded.
Except the imageset used by the StaticImage, I did not create other imagesets. So are there some default imagesets that be used by UI?

Posted: Fri Jan 18, 2008 17:54
by Rackle
A scheme (Taharez, Windows, or other) makes use of an image to visually describe the components of widgets (corners of a button). This image may be created automatically and may be what gets destroyed through destoryAllImagesets().

In terms of code cleanliness this version is much better. Imagine in a month or two adding another image and some of the time this new image bugs out. This code is more precise.