Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: wxLearner on February 23, 2007, 12:05:39 pm

Title: Solution to small bug in wxSmith
Post by: wxLearner on February 23, 2007, 12:05:39 pm
Hello,
the wxStdDialogButtonSizer doesn't work. I've looked into the code and the reason seems to be, that it cannot be converted to a parent:
Quote from: wxsitemfactory.cpp
Code
case wxsTContainer:
case wxsTSizer:
    if ( !Item->ConvertToParent() )
    {
        // Fake item
        delete Item;
        return NULL;
    }
    break;
Since wxsStdDialogButtonSizer doesn't inherit wxsSizer (like the other sizers do), but wxsItem, the conversion to parent fails and it isn't returned.
The (maybe not nicest, but quick) solution to this issue could be the following change of the if-statement:
Code
if ( !Item->ConvertToParent() && Item->GetClassName() != wxT("wxStdDialogButtonSizer") )
Title: Re: Solution to small bug in wxSmith
Post by: byo on February 23, 2007, 05:14:11 pm
Hello,
the wxStdDialogButtonSizer doesn't work. I've looked into the code and the reason seems to be, that it cannot be converted to a parent:
Quote from: wxsitemfactory.cpp
Code
case wxsTContainer:
case wxsTSizer:
    if ( !Item->ConvertToParent() )
    {
        // Fake item
        delete Item;
        return NULL;
    }
    break;
Since wxsStdDialogButtonSizer doesn't inherit wxsSizer (like the other sizers do), but wxsItem, the conversion to parent fails and it isn't returned.
The (maybe not nicest, but quick) solution to this issue could be the following change of the if-statement:
Code
if ( !Item->ConvertToParent() && Item->GetClassName() != wxT("wxStdDialogButtonSizer") )

Whoops  :oops:. I've added these is-parent extra checking recently and forgot that wxStdDialogButtonSizer in fact isn't a parent. Hmm, and in fact, there's no requirement that wxSizer-like classes must allow adding children. One may create custom class working simillar to wxStdDiaogButtonSizer, so probably removing case wxsTSizer: is best solition.

Thanks for finding this bug :)

Regards
   BYO