Custom Resource Provider Fail

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

Excizted
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Feb 23, 2010 22:16

Custom Resource Provider Fail

Postby Excizted » Fri Apr 16, 2010 17:06

Hello,

I've tried to create my own ResourceProvider for CEGUI to integrate into my own Resource System.

Some of the functions may appear to look like OGRE, but it far from is...

Code: Select all

    void CEGUIResourceProvider::loadRawDataContainer(const CEGUI::String& filename, CEGUI::RawDataContainer& output, const CEGUI::String& resourceGroup)
    {
        DataStream* stream = m_Resources->openResource(filename.c_str(), resourceGroup.c_str());
        if(stream == NULL)
        {
            m_Root->log()->writeLog("Error! Could not load " + String(filename.c_str()) + " from group " + String(resourceGroup.c_str()) + "!");
            return;
        }
        m_Root->log()->debugLog("CEGUIResourceProvider::loadRawDataContainer: Opened file " + String(filename.c_str()) + " successfully!");
        CEGUI::uint8* buf = new CEGUI::uint8;
        stream->read(buf, stream->getSize());
        output.setData(buf);
        output.setSize(stream->getSize());
        m_Root->log()->debugLog("CEGUIResourceProvider::loadRawDataContainer: Provided " + String(filename.c_str()) + " with size " + StringConverter::toString(int(stream->getSize())) + " successfully!");
    }

    void CEGUIResourceProvider::unloadRawDataContainer(CEGUI::RawDataContainer& c)
    {
    }

    size_t CEGUIResourceProvider::getResourceGroupFileNames(std::vector<CEGUI::String>& out_vec, const CEGUI::String& file_pattern, const CEGUI::String& resource_group)
    {
        ResourceGroup* group = m_Resources->getGroup(String(resource_group.c_str()));
        if(group == NULL)
        {
            m_Root->log()->writeLog("CEGUIResourceProvider::getResourceGroupFileNames: No such group (" + String(resource_group.c_str()) + ")!");
            return 0;
        }

        const Stringvector v = group->getResourceFileNames();
       
        for(Stringvector::const_iterator it = v.begin(); it != v.end(); ++it)
        {
            out_vec.push_back(*it);
        }

        m_Root->log()->debugLog("CEGUIResourceProvider::getResourceGroupFilenames: Read " + StringConverter::toString(int(out_vec.size())) + " of " + StringConverter::toString(int(v.size())) + " files from resource group " + resource_group.c_str());

        return v.size();
    }


Really strange things happen in run-time... And worst of all - each time I start it up, a new issue appears.

Just one of them, a segmentation fault (also had Sigabort)


CEGUITinyXMLParser.cpp:69
- Segmentation fault here... Debugger resolves size to 1957 which is matching the file being loaded.

Code: Select all

char* buf = new char[size + 2];


Any clues ? :/

My Log doesn't tell anything, but heres the 'essential part' anyway:

Code: Select all

16/04/2010 19:03:10 (Std)    ---- Version 0.7.1 (Build: Apr 16 2010 GNU/Linux g++ 4.4.1 64 bit) ----
16/04/2010 19:03:10 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
16/04/2010 19:03:10 (Std)    ---- XML Parser module is: CEGUI::TinyXMLParser - Official tinyXML based parser module for CEGUI ----
16/04/2010 19:03:10 (Std)    ---- Image Codec module is: TGAImageCodec - Official TGA image codec ----
16/04/2010 19:03:10 (Std)    ---- Scripting module is: None ----

Excizted
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Feb 23, 2010 22:16

Re: Custom Resource Provider Fail

Postby Excizted » Sun Apr 18, 2010 12:53

I just remembered that my resource system is not yet thread safe - could this be an issue ??

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Custom Resource Provider Fail

Postby CrazyEddie » Mon Apr 19, 2010 09:07

In loadRawDataContainer you only allocate a single byte buffer, and then proceed to load the resource into that single byte buffer!

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 0 guests