1) Load base resources A.
2) Load extra resources B.
3) Unload extra resources B.
4) Load extra resources C that are just different versions of resources B (same names, different pictures)
I can't find a good way to do this.
I found this thread http://cegui.org.uk/forum/viewtopic.php?f=10&t=6586 was helpful and relevant.
My suggestion is that CEGUI should have a better way to handle loading and unloading blocks of resources. I want to unload all images relevant to B, but not unload anything in A. That's really tough to do right now.
Anyway, back to my problem. My workaround is:
1) Load base resources A.
2) Load extra resources B.
3) Unload all resources.
4) Load base resources A.
5) Load base resources C.
The issue I am having with this is I get access violation reading location 0xABABABAB when attempting to reload the layout in resources A. I can reload the schemes, imagesets, and fonts without exception.
CEGUI/Window.cpp where the exception is thrown
Code: Select all
const RenderedString& Window::getRenderedString() const
{
if (!d_renderedStringValid)
{
// FIXME: Evil const cast!
d_renderedString = getRenderedStringParser().parse(
getTextVisual(), const_cast<Font*>(getFont()), 0); // ** THIS LINE **
d_renderedStringValid = true;
}
return d_renderedString;
}
My call stack:
Code: Select all
msvcr120d.dll!00ab33be() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120d.dll]
> CEGUIBase-0_d.dll!CEGUI::Window::getRenderedString() Line 3367 C++
CEGUICoreWindowRendererSet_d.dll!CEGUI::FalagardStaticText::setupStringFormatter() Line 504 C++
CEGUICoreWindowRendererSet_d.dll!CEGUI::FalagardStaticText::updateFormatting(const CEGUI::Size<float> & sz) Line 586 C++
CEGUICoreWindowRendererSet_d.dll!CEGUI::FalagardStaticText::getDocumentSize(const CEGUI::Rect<float> & renderArea) Line 268 C++
CEGUICoreWindowRendererSet_d.dll!CEGUI::FalagardStaticText::configureScrollbars() Line 344 C++
CEGUICoreWindowRendererSet_d.dll!CEGUI::FalagardStaticText::onSized(const CEGUI::EventArgs & __formal) Line 390 C++
CEGUICoreWindowRendererSet_d.dll!CEGUI::MemberFunctionSlot<CEGUI::FalagardStaticText>::operator()(const CEGUI::EventArgs & args) Line 55 C++
CEGUIBase-0_d.dll!CEGUI::SubscriberSlot::operator()(const CEGUI::EventArgs & args) Line 83 C++
CEGUIBase-0_d.dll!CEGUI::Event::operator()(CEGUI::EventArgs & args) Line 103 C++
CEGUIBase-0_d.dll!CEGUI::EventSet::fireEvent_impl(const CEGUI::String & name, CEGUI::EventArgs & args) Line 199 C++
CEGUIBase-0_d.dll!CEGUI::EventSet::fireEvent(const CEGUI::String & name, CEGUI::EventArgs & args, const CEGUI::String & eventNamespace) Line 160 C++
CEGUIBase-0_d.dll!CEGUI::Window::onSized(CEGUI::ElementEventArgs & e) Line 2206 C++
CEGUIBase-0_d.dll!CEGUI::Element::fireAreaChangeEvents(const bool moved, const bool sized) Line 536 C++
CEGUIBase-0_d.dll!CEGUI::Element::setArea_impl(const CEGUI::Vector2<CEGUI::UDim> & pos, const CEGUI::Size<CEGUI::UDim> & size, bool topLeftSizing, bool fireEvents) Line 522 C++
CEGUIBase-0_d.dll!CEGUI::Window::setArea_impl(const CEGUI::Vector2<CEGUI::UDim> & pos, const CEGUI::Size<CEGUI::UDim> & size, bool topLeftSizing, bool fireEvents) Line 1840 C++
CEGUIBase-0_d.dll!CEGUI::Element::setArea(const CEGUI::Vector2<CEGUI::UDim> & pos, const CEGUI::Size<CEGUI::UDim> & size) Line 100 C++
CEGUIBase-0_d.dll!CEGUI::Element::setArea(const CEGUI::Rect<CEGUI::UDim> & area) Line 451 C++
CEGUIBase-0_d.dll!CEGUI::TplWindowProperty<CEGUI::Element,CEGUI::Rect<CEGUI::UDim> >::setNative_impl(CEGUI::PropertyReceiver * receiver, const CEGUI::Rect<CEGUI::UDim> & value) Line 62 C++
CEGUIBase-0_d.dll!CEGUI::TypedProperty<CEGUI::Rect<CEGUI::UDim> >::setNative(CEGUI::PropertyReceiver * receiver, const CEGUI::Rect<CEGUI::UDim> & value) Line 84 C++
CEGUIBase-0_d.dll!CEGUI::TypedProperty<CEGUI::Rect<CEGUI::UDim> >::set(CEGUI::PropertyReceiver * receiver, const CEGUI::String & value) Line 73 C++
CEGUIBase-0_d.dll!CEGUI::PropertySet::setProperty(const CEGUI::String & name, const CEGUI::String & value) Line 142 C++
CEGUIBase-0_d.dll!CEGUI::GUILayout_xmlHandler::elementPropertyStart(const CEGUI::XMLAttributes & attributes) Line 370 C++
CEGUIBase-0_d.dll!CEGUI::GUILayout_xmlHandler::elementStart(const CEGUI::String & element, const CEGUI::XMLAttributes & attributes) Line 89 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLDocument::processElement(const TiXmlElement * element) Line 122 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLDocument::processElement(const TiXmlElement * element) Line 132 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLDocument::processElement(const TiXmlElement * element) Line 132 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLDocument::processElement(const TiXmlElement * element) Line 132 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLDocument::processElement(const TiXmlElement * element) Line 132 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLDocument::TinyXMLDocument(CEGUI::XMLHandler & handler, const CEGUI::RawDataContainer & source, const CEGUI::String & __formal) Line 96 C++
CEGUITinyXMLParser_d.dll!CEGUI::TinyXMLParser::parseXML(CEGUI::XMLHandler & handler, const CEGUI::RawDataContainer & source, const CEGUI::String & schemaName) Line 159 C++
CEGUIBase-0_d.dll!CEGUI::XMLParser::parseXMLFile(CEGUI::XMLHandler & handler, const CEGUI::String & filename, const CEGUI::String & schemaName, const CEGUI::String & resourceGroup) Line 66 C++
CEGUIBase-0_d.dll!CEGUI::WindowManager::loadLayoutFromFile(const CEGUI::String & filename, const CEGUI::String & resourceGroup, bool (CEGUI::Window *, CEGUI::String &, CEGUI::String &, void *) * callback, void * userdata) Line 290 C++
DP.exe!dp::GuiWindow::Initialize(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & mod_name, const dp::UiType & ui) Line 28 C++
DP.exe!dp::ProgressScreen::Initialize(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & mod_name, const dp::UiType & ui) Line 11 C++
DP.exe!dp::ClientApp::LoadGuiNext() Line 169 C++
DP.exe!dp::ClientApp::Render() Line 83 C++
DP.exe!ceguiapp::CeguiApp::DrawFrame() Line 226 C++
DP.exe!ceguiapp::CeguiApp::Run() Line 88 C++
DP.exe!main(int argc, char * * argv) Line 29 C++
[External Code]
My unload and reload process:
Code: Select all
// unload all
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(NULL);
WindowManager::getSingleton().destroyAllWindows();
SchemeManager::getSingleton().destroyAll();
FontManager::getSingleton().destroyAll();
ImageManager::getSingleton().destroyAll();
// reload resources A
for (string const& s : ui.GetSchemes()) {
SchemeManager::getSingleton().createFromFile(s, Path::Get().SchemeFileResourceGroupName(mod_name, s));
}
for (string const& s : ui.GetImagesets()) {
ImageManager::getSingleton().loadImageset(s, Path::Get().ImagesetFileResourceGroupName(mod_name, s));
}
for (string const& s : ui.GetFonts()) {
FontManager::getSingleton().createFromFile(s, Path::Get().FontFileResourceGroupName(mod_name, s));
}
root = WindowManager::getSingleton().loadLayoutFromFile(ui.GetLayout(), Path::Get().LayoutFileResourceGroupName(mod_name, ui.GetLayout())); // ** THIS LINE **
if (root == nullptr) throw runtime_error("Layout file (" + ui.GetLayout() + ") failed to load.");
Finally my CEGUI.log
Code: Select all
13/05/2014 10:21:18 (Std) ---- Version: 0.8.3 (Build: May 12 2014 Debug Microsoft Windows MSVC++ Great Scott! 32 bit) ----
13/05/2014 10:21:18 (Std) ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module. TextureTarget support enabled via FBO extension. ----
13/05/2014 10:21:18 (Std) ---- XML Parser module is: CEGUI::TinyXMLParser - Official tinyXML based parser module for CEGUI ----
13/05/2014 10:21:18 (Std) ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
13/05/2014 10:21:18 (Std) ---- Scripting module is: None ----
Any help or suggestions (if there is an easier way to do this) would be welcome.
Thanks.