[solved] Freeze-Crash Resizing a Button to a Point

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

crodgers
Just popping in
Just popping in
Posts: 3
Joined: Wed Apr 28, 2010 14:43

[solved] Freeze-Crash Resizing a Button to a Point

Postby crodgers » Thu Aug 26, 2010 15:49

Hi CrazyEddie!

Let me start by saying that I really like the CEGUI project. I have used it for projects at work for 3+ years, mostly for the BBN VESSEL Damage Control Simulator, which won a couple awards over the past year: http://www.bbn.com/technology/immersive_learning_technologies/vessel

We have been working with CEGUI 0.6.x (with OpenGL rendering) for that project. In the game, several controls animate their size and position to help direct the players' eyes to important information and interface. All had been working fine until we ported over to CEGUI 0.7 when we encountered a strange freeze-crash that happened when scaling any button (with text) down to a point.

It turns out that the freeze was an infinite while-loop in RenderedStringWordWrapper::format. It would eventually crash because of the infinitely growing vector of lines, "d_lines".

Code: Select all

void RenderedStringWordWrapper<T>::format(const Size& area_size)
{
    deleteFormatters();

    RenderedString rstring, lstring;
    rstring = *d_renderedString;
    float rs_width;

    T* frs;

    for (size_t line = 0; line < rstring.getLineCount(); ++line)
    {
        while ((rs_width = rstring.getPixelSize(line).d_width) > 0)
        {
            // skip line if no wrapping occurs
            if (rs_width <= area_size.d_width)
                break;

            // split rstring at width into lstring and remaining rstring
            rstring.split(line, area_size.d_width, lstring);
            frs = new T(*new RenderedString(lstring));
            frs->format(area_size);
            d_lines.push_back(frs);
            line = 0;
        }
    }

    // last line.
    frs = new T(*new RenderedString(rstring));
    frs->format(area_size);
    d_lines.push_back(frs);
}

The break statement in the loop was never hit. At the point I was debugging, it was trying to split a single component (16 pixels wide) while the text area was pinched down to nearly a point (10 pixels wide).

For lack of other methods on RenderedString, I added this slightly hackish snip of code (as a fail-safe) right after the call to split:

Code: Select all

            if(rstring.getComponentCount() == 1 && rstring.getLineCount() == 1 && rs_width >= area_size.d_width)
               break;

I could have added a canSplit method to RenderedString, in order to simplify the if-statment, though I wanted to keep modifications to CEGUI to a minimum.

Hopefully this fix or something similar can make it into the next version of CEGUI. By the way, looking forward to the animation support in 0.7.2 :)

Thanks a bunch for your awesome work CrazyEddie!

Cheers,

Chris
Last edited by crodgers on Fri Aug 27, 2010 13:50, edited 1 time in total.

Timo
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Sun Feb 14, 2010 09:38

Re: Freeze-Crash Resizing a Button to a Point

Postby Timo » Fri Aug 27, 2010 05:45

I'm 95% sure this has been fixed in the SVN version and latest snapshots.

Oh Eddie, you should release 0.7.2 already. :D

edit: ok, I see it's coming soon...

crodgers
Just popping in
Just popping in
Posts: 3
Joined: Wed Apr 28, 2010 14:43

Re: Freeze-Crash Resizing a Button to a Point

Postby crodgers » Fri Aug 27, 2010 13:48

Thanks Timo :)

Looking forward to upgrading once the official release is available.

Cheers!


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 2 guests