Author Topic: Solution to small bug in wxSmith  (Read 3698 times)

wxLearner

  • Guest
Solution to small bug in wxSmith
« 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") )
« Last Edit: February 23, 2007, 12:14:52 pm by wxLearner »

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Solution to small bug in wxSmith
« Reply #1 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