Project

General

Profile

Bug #1347 ยป main.cpp

test case - Steve Drake, 07/03/2012 04:38 PM

 
//============================================================================
// Test case: pasting control character into WLineEdit causes 'lockup'
//
// Steps:
// - Build the app
// - Start it
// - Open web app in browser
// - Copy a control character (such as 0x07) into clipboard
// - Paste the control character into the WLineEdit field
//
// Results:
// - Web app shows "Loading..." forever and CPU utilization goes to 100%
//
// Notes:
// - Test environment was: Ubuntu 10.04, FireFox 13.0.1, Wt 3.2.1
// - Getting a control character into the clipboard may require creative use
// of an editor (I used SlickEdit and used the Insert Literal feature).
// - If there is no event handler attached to the WLineEdit widget then the
// problem does not occur.
//============================================================================

#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WText>
#include <Wt/WLineEdit>

class MyWidget : public Wt::WContainerWidget
{
public:
MyWidget(Wt::WContainerWidget* parent = 0);
~MyWidget();
private slots:
void eventHandler(void);
private:
Wt::WLineEdit* edit;
int count;
};

void MyWidget::eventHandler(void)
{
count++;
}

MyWidget::MyWidget(Wt::WContainerWidget* parent) : WContainerWidget(parent), count(0)
{
addWidget(new Wt::WText(Wt::WString("Enter some text:")));
edit = new Wt::WLineEdit();
addWidget(edit);
edit->keyWentUp().connect(this, &MyWidget::eventHandler);
}

MyWidget::~MyWidget()
{
}

class MyApplication : public Wt::WApplication
{
public:
MyApplication(const Wt::WEnvironment& env);
private:
void createUi();
};

MyApplication::MyApplication(const Wt::WEnvironment& env) : Wt::WApplication(env)
{
createUi();
}

void MyApplication::createUi()
{
root()->addWidget(new MyWidget());
}

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
MyApplication* myApp;

myApp = new MyApplication(env);

return myApp;
}

int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, &createApplication);
}

    (1-1/1)