Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#19 ModalDialog with radio buttons

open
nobody
None
5
2007-07-15
2007-07-15
andrew7
No

Exception if groupbox+radio button in a modal
Delete By: dali_bude (dali_bude) - 2007-07-06 16:36
Hi,

This very simple code gives an "non_rtti_object" exception when compiled and run from Visual C++ 2005 (8.0). This happenns in in messagemap.h, line 313 (topmost relevant function).

Scenario: run, open the dialog from menu, close the dialog, try to access the menu again. On handling the menu message, the exception is thrown.

Everything will be fine if no radio button is added to the group.

Complete project and stack dump here: http://yp.lviv.ua/philez/swcrash.zip . Library version is 2.0 RC5.

Where's the bug?

-------------

#include "SmartWin.h"
using namespace SmartWin;

class RuleDialog : public WidgetFactory< WidgetModalDialog, RuleDialog, SmartWin::MessageMapPolicyModalDialogWidget >
{
WidgetGroupBoxPtr itsActionGroup;
WidgetRadioButtonPtr itsActionRadioShow;

public:

bool setUp()
{
setBounds( 500,300,430,330 , true );

itsActionGroup = createGroupBox();
itsActionGroup->setBounds(10,90,200,80);
itsActionGroup->setText(_T("grp"));

itsActionRadioShow = createRadioButton(itsActionGroup);
itsActionRadioShow->setBounds(10,15,100,30);
return true;
}

RuleDialog(Widget *parent) : Widget( parent )
{
onInitDialog(&RuleDialog::setUp);
}
};

class HelloWinClass
: public WidgetFactory< WidgetWindow, HelloWinClass >
{
private:
WidgetMenuPtr itsMainMenu;
public:
void menuRules( WidgetMenuPtr menu, unsigned item )
{
RuleDialog ruleDlg(this);
ruleDlg.createDialog();
}
void initAndCreate()
{
createWindow();

itsMainMenu = createMenu();
WidgetMenuPtr file = itsMainMenu->appendPopup( _T("&Menu") );
file->appendItem( 1, _T("Rules..."), &HelloWinClass::menuRules );

itsMainMenu->attach( this );
}

};

int SmartWinMain( Application & app )
{
HelloWinClass * testHello = new HelloWinClass;
testHello->initAndCreate();
return app.run();
}

--------------

This was reproduced, and deal with the tricky logic to kill widgets.

Discussion