Skip to content

Commit

Permalink
Several changes:
Browse files Browse the repository at this point in the history
    - fix build warnings (CLang)
    - fixed issue #2910
    - fix websocket response including connection header: upgrade, close (#2925)
    - make WMemoryResource's methods not crash on null data (#2810)
  • Loading branch information
Koen Deforche committed Apr 11, 2014
1 parent 2997d5c commit 1aca2f1
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 43 deletions.
2 changes: 0 additions & 2 deletions examples/blog/view/BlogView.C
Expand Up @@ -47,7 +47,6 @@ public:
: basePath_(basePath),
rssFeedUrl_(rssFeedUrl),
session_(connectionPool),
blogView_(blogView),
panel_(0),
authorPanel_(0),
users_(0),
Expand Down Expand Up @@ -117,7 +116,6 @@ public:
private:
std::string basePath_, rssFeedUrl_;
BlogSession session_;
BlogView *blogView_;
BlogLoginWidget *loginWidget_;

WStackedWidget* panel_;
Expand Down
2 changes: 2 additions & 0 deletions examples/blog/view/PostView.h
Expand Up @@ -56,6 +56,8 @@ class PostView : public Wt::WTemplate
void rm();

void setState(Post::State state);

using WWebWidget::render;
};

#endif // POST_VIEW_H_
2 changes: 2 additions & 0 deletions examples/charts/PanelList.h
Expand Up @@ -22,6 +22,8 @@ class PanelList : public Wt::WContainerWidget
void addPanel(Wt::WPanel *panel);
void removePanel(Wt::WPanel *panel);

using WContainerWidget::addWidget;

private:
void onExpand(bool notUndo);

Expand Down
1 change: 0 additions & 1 deletion examples/feature/paypal/PayPalExample.C
Expand Up @@ -67,7 +67,6 @@ private:
Wt::WDialog *dialog_;
Wt::WText *dialogText_;
Wt::WPushButton *dialogCancelButton_;
Wt::WGridLayout *outputTable_;

void reviewOrder()
{
Expand Down
1 change: 1 addition & 0 deletions examples/hangman/HangmanWidget.C
Expand Up @@ -13,6 +13,7 @@
#include <boost/lexical_cast.hpp>

#include "Session.h"
#include "Dictionary.h"
#include "WordWidget.h"
#include "ImagesWidget.h"
#include "LettersWidget.h"
Expand Down
3 changes: 0 additions & 3 deletions examples/hangman/HangmanWidget.h
Expand Up @@ -12,8 +12,6 @@

#include <Wt/WContainerWidget>

#include "Dictionary.h"

class Session;
class WordWidget;
class ImagesWidget;
Expand All @@ -40,7 +38,6 @@ class HangmanWidget: public Wt::WContainerWidget
Wt::Signal<int> scoreUpdated_;

std::string name_;
Dictionary dictionary_;

int badGuesses_;

Expand Down
1 change: 0 additions & 1 deletion examples/mission/CountDownWidget.h
Expand Up @@ -45,7 +45,6 @@ class CountDownWidget : public WText
Wt::Signal<void> done_;
int start_;
int stop_;
unsigned msec_;

int current_;

Expand Down
1 change: 0 additions & 1 deletion examples/simplechat/SimpleChatWidget.h
Expand Up @@ -93,7 +93,6 @@ class SimpleChatWidget : public Wt::WContainerWidget,
Wt::WText *statusMsg_;

Wt::WContainerWidget *messages_;
Wt::WContainerWidget *messageEditArea_;
Wt::WTextArea *messageEdit_;
Wt::WPushButton *sendButton_;
Wt::WContainerWidget *userList_;
Expand Down
5 changes: 3 additions & 2 deletions src/Wt/WDoubleSpinBox.C
Expand Up @@ -14,13 +14,14 @@ namespace Wt {

WDoubleSpinBox::WDoubleSpinBox(WContainerWidget *parent)
: WAbstractSpinBox(parent),
setup_(false),
value_(-1),
min_(0.0),
max_(99.99),
step_(1.0),
precision_(2),
valueChanged_(this)
{
{
setValidator(createValidator());
setValue(0.0);
}
Expand Down Expand Up @@ -78,7 +79,7 @@ void WDoubleSpinBox::setDecimals(int decimals)
setText(textFromValue());
}

std::string WDoubleSpinBox::jsMinMaxStep() const
std::string WDoubleSpinBox::jsMinMaxStep() const
{
return boost::lexical_cast<std::string>(min_) + ","
+ boost::lexical_cast<std::string>(max_) + ","
Expand Down
8 changes: 7 additions & 1 deletion src/Wt/WMemoryResource.C
Expand Up @@ -93,7 +93,10 @@ const std::vector<unsigned char> WMemoryResource::data() const
data = data_;
}

return *data;
if (!data)
return std::vector<unsigned char>();
else
return *data;
}

void WMemoryResource::handleRequest(const Http::Request& request,
Expand All @@ -107,6 +110,9 @@ void WMemoryResource::handleRequest(const Http::Request& request,
data = data_;
}

if (!data)
return;

response.setMimeType(mimeType_);

for (unsigned int i = 0; i < (*data).size(); ++i)
Expand Down
25 changes: 0 additions & 25 deletions src/http/Connection.C
Expand Up @@ -25,31 +25,6 @@
#include "Server.h"
#include "WebController.h"

/*
* We need a re-design:
* Connection has a request parser and a read-callback
* After each read operation:
* - request parser is used to determine state
* - read-callback is cleared, and called with state.
* this may update read-callback and write callback
* - when a read or write callback is set:
* start write operation -> request parser -> write callback
* start write operation -> write callback
* these may update read-callback and write callback
* - when not reading or writing: we may finish the request or wait for more
* new events may be posted out of the blue by setting a callback (and data)
* Most important change: callbacks are set to the Connection, and the
* request parser is no longer in charge.
*/

/*
* Reply holds Connection shared_ptr
* When we get an error during read body / write response
* we indicate that to the reply which should result in a ~HttpRequest
* I/O to a closed connection:
* we indicate that to the reply which should result in a ~HttpRequest
*/

namespace Wt {
LOGGER("wthttp/async");
}
Expand Down
2 changes: 1 addition & 1 deletion src/http/Reply.C
Expand Up @@ -398,7 +398,7 @@ bool Reply::nextBuffers(std::vector<asio::const_buffer>& result)
/*
* Connection
*/
if (closeConnection_) {
if (closeConnection_ && request_.webSocketVersion < 0) {
buf_ << "Connection: close\r\n";
} else {
if (http10) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/WSpinBox.js
Expand Up @@ -129,7 +129,7 @@ WT_DECLARE_WT_MEMBER
stepValue = aStep;
precision = aPrecision;

var Validator = isDoubleSpinBox ? WT.WDoubleValidator : WT.WIntValidator;
var Validator = isDoubleSpinBox || WT.WIntValidator === undefined ? WT.WDoubleValidator : WT.WIntValidator;

validator = new Validator(true, minValue, maxValue,
NaNError, NaNError,
Expand Down
6 changes: 1 addition & 5 deletions src/js/WSpinBox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1aca2f1

Please sign in to comment.