|
#include <string>
|
|
#include <iostream>
|
|
|
|
#include <Wt/WText>
|
|
#include <Wt/WBreak>
|
|
#include <Wt/WDialog>
|
|
#include <Wt/WLineEdit>
|
|
#include <Wt/WGridLayout>
|
|
#include <Wt/WPushButton>
|
|
#include <Wt/WApplication>
|
|
#include <Wt/WContainerWidget>
|
|
|
|
using namespace std;
|
|
using namespace Wt;
|
|
|
|
class CrashingApplication : public WApplication
|
|
{
|
|
public:
|
|
CrashingApplication(const WEnvironment& env);
|
|
virtual ~CrashingApplication()
|
|
{
|
|
std::cout << "Destructing CrashingApplication " << sessionId() << std::endl
|
|
<< "Will crash dereferencing a NULL pointer in WDialog::cover()"
|
|
<< std::endl;
|
|
}
|
|
|
|
|
|
private:
|
|
WLineEdit *nameEdit_;
|
|
WText *greeting_;
|
|
WDialog *dialog_;
|
|
WGridLayout *layout_;
|
|
WContainerWidget *greensqare_;
|
|
|
|
void greet();
|
|
};
|
|
|
|
void deldialog( WDialog *&w )
|
|
{
|
|
if( w )
|
|
delete w;
|
|
w = 0;
|
|
}
|
|
|
|
CrashingApplication::CrashingApplication(const WEnvironment& env)
|
|
: WApplication(env)
|
|
{
|
|
std::cout << "Creating CrashingApplication" << sessionId() << std::endl;
|
|
|
|
WDialog *firstwind = new WDialog( "My Problem window" );
|
|
firstwind->setModal( false );
|
|
new WText( "Be ready for a seg-fault when session terminates",
|
|
firstwind->contents() );
|
|
firstwind->show();
|
|
|
|
setTitle("Hello world");
|
|
|
|
layout_ = new WGridLayout( root() );
|
|
greeting_ = new WText("Be ready for a seg-fault when session terminates");
|
|
layout_->addWidget( greeting_, 0, 0, 1, 3 );
|
|
|
|
nameEdit_ = new WLineEdit();
|
|
nameEdit_->enterPressed().connect( this, &CrashingApplication::greet );
|
|
layout_->addWidget( nameEdit_, 1, 0 );
|
|
|
|
WPushButton *button = new WPushButton("Okay");
|
|
layout_->addWidget( button, 1, 1 );
|
|
|
|
greensqare_ = new WContainerWidget();
|
|
greensqare_->setAttributeValue( "style", "background:green" );
|
|
layout_->addWidget(greensqare_, 2, 0, 1, 3 );
|
|
|
|
layout_->setRowStretch( 2, 10 );
|
|
layout_->setColumnStretch( 2, 10 );
|
|
|
|
//In order for the column stretch call above to have an effect, we need this
|
|
// next line, which I wouldnt think we would
|
|
layout_->addWidget( new WContainerWidget(), 1, 2 );
|
|
|
|
|
|
dialog_ = new WDialog( "Example Dialog" );
|
|
dialog_->setModal( false );
|
|
dialog_->setHidden( false, WAnimation() );
|
|
dialog_->resize( 300, 250 );
|
|
dialog_->setClosable( true );
|
|
dialog_->finished().connect( boost::bind( &deldialog, boost::ref(dialog_)) );
|
|
new WText( "This dialog wont cause a problem if you close it, but the dialog "
|
|
"you cant close will!", dialog_->contents() );
|
|
}
|
|
|
|
void CrashingApplication::greet()
|
|
{
|
|
greeting_->setText(greeting_->text() + nameEdit_->text());
|
|
}
|
|
|
|
WApplication *createApplication(const WEnvironment& env)
|
|
{
|
|
return new CrashingApplication(env);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
return WRun(argc, argv, &createApplication);
|
|
}
|
|
|