Skip to content

Commit 8d02146

Browse files
author
Koen Deforche
committed
see Changelog
1 parent a369471 commit 8d02146

18 files changed

+171
-80
lines changed

Changelog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
19-03-2010:
2+
* WCheckBox, WRadioButton: fix inconsistencies when setting style
3+
attributes and they have a non-empty label
4+
15
15-03-2010:
26
* Dbo/backend/Postgres: a PostgreSQL backend, contributed by Hilary
37
Cheng

examples/simplechat/SimpleChatWidget.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ void SimpleChatWidget::updateUsers()
223223

224224
for (SimpleChatServer::UserSet::iterator i = users.begin();
225225
i != users.end(); ++i) {
226-
WContainerWidget *line = new WContainerWidget(userList_);
227-
WCheckBox *w = new WCheckBox(*i, line);
226+
WCheckBox *w = new WCheckBox(*i, userList_);
227+
w->setInline(false);
228228

229229
UserMap::const_iterator j = oldUsers.find(*i);
230230
if (j != oldUsers.end())
@@ -236,7 +236,7 @@ void SimpleChatWidget::updateUsers()
236236
w->changed().connect(SLOT(this, SimpleChatWidget::updateUser));
237237

238238
if (*i == user_)
239-
line->setStyleClass("chat-self");
239+
w->setStyleClass("chat-self");
240240
}
241241
}
242242

src/Wt/WAbstractToggleButton

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected:
109109
virtual DomElement *createDomElement(WApplication *app);
110110
virtual void getDomChanges(std::vector<DomElement *>& result,
111111
WApplication *app);
112-
virtual void updateDom(DomElement& element, bool all);
112+
virtual void updateDomElements(DomElement& el, DomElement& input, bool all);
113113
virtual void getFormObjects(FormObjectsMap& formObjects);
114114
virtual void setFormData(const FormData& formData);
115115
virtual void propagateRenderOk(bool deep);

src/Wt/WAbstractToggleButton.C

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,9 @@ void WAbstractToggleButton::undoSetUnChecked()
122122
undoSetChecked();
123123
}
124124

125-
void WAbstractToggleButton::updateDom(DomElement& element, bool all)
125+
void WAbstractToggleButton::updateDomElements(DomElement& element,
126+
DomElement& input, bool all)
126127
{
127-
if (stateChanged_ || all) {
128-
element.setProperty(Wt::PropertyChecked,
129-
state_ == Checked ? "true" : "false");
130-
131-
if (!useImageWorkaround())
132-
element.setProperty(Wt::PropertyIndeterminate,
133-
state_ == PartiallyChecked ? "true" : "false");
134-
135-
stateChanged_ = false;
136-
}
137-
138128
const WEnvironment& env = WApplication::instance()->environment();
139129

140130
EventSignal<> *check = voidEventSignal(CHECKED_SIGNAL, false);
@@ -149,10 +139,31 @@ void WAbstractToggleButton::updateDom(DomElement& element, bool all)
149139
|| (check && check->needUpdate())
150140
|| (uncheck && uncheck->needUpdate()));
151141

152-
WFormWidget::updateDom(element, all);
142+
updateDom(input, all);
143+
144+
/*
145+
* Copy all properties to the exterior element, as they relate to style,
146+
* etc... We ignore here attributes, see WWebWidget: there seems not to
147+
* be attributes that sensibly need to be moved.
148+
*/
149+
if (&element != &input) {
150+
element.setProperties(input.properties());
151+
input.clearProperties();
152+
}
153+
154+
if (stateChanged_ || all) {
155+
input.setProperty(Wt::PropertyChecked,
156+
state_ == Checked ? "true" : "false");
157+
158+
if (!useImageWorkaround())
159+
input.setProperty(Wt::PropertyIndeterminate,
160+
state_ == PartiallyChecked ? "true" : "false");
161+
162+
stateChanged_ = false;
163+
}
153164

154165
if (needUpdateClickedSignal || all) {
155-
std::string dom = WT_CLASS ".getElement('" + element.id() + "')";
166+
std::string dom = WT_CLASS ".getElement('" + input.id() + "')";
156167
std::vector<DomElement::EventAction> actions;
157168

158169
if (check) {
@@ -196,7 +207,7 @@ void WAbstractToggleButton::updateDom(DomElement& element, bool all)
196207
}
197208

198209
if (!(all && actions.empty()))
199-
element.setEvent("click", actions);
210+
input.setEvent("click", actions);
200211
}
201212
}
202213

@@ -264,7 +275,7 @@ DomElement *WAbstractToggleButton::createDomElement(WApplication *app)
264275
}
265276
}
266277

267-
updateDom(*input, true);
278+
updateDomElements(*result, *input, true);
268279

269280
if (result != input) {
270281
result->addChild(input);
@@ -281,19 +292,19 @@ DomElement *WAbstractToggleButton::createDomElement(WApplication *app)
281292
void WAbstractToggleButton::getDomChanges(std::vector<DomElement *>& result,
282293
WApplication *app)
283294
{
284-
DomElementType type = domElementType();
285-
286-
if (type == DomElement_SPAN) {
295+
DomElement *element = DomElement::getForUpdate(this, domElementType());
296+
if (element->type() == DomElement_SPAN) {
287297
DomElement *input
288298
= DomElement::getForUpdate("in" + id(), DomElement_INPUT);
289299

300+
updateDomElements(*element, *input, false);
301+
290302
if (useImageWorkaround()) {
291303
EventSignal<> *imgClick = voidEventSignal(UNDETERMINATE_CLICK_SIGNAL,
292304
true);
293305

294306
if (stateChanged_ || imgClick->needUpdate()) {
295-
DomElement *img
296-
= DomElement::getForUpdate("im" + id(), DomElement_IMG);
307+
DomElement *img = DomElement::getForUpdate("im" + id(), DomElement_IMG);
297308

298309
if (stateChanged_) {
299310
img->setProperty(Wt::PropertyStyleDisplay,
@@ -311,12 +322,11 @@ void WAbstractToggleButton::getDomChanges(std::vector<DomElement *>& result,
311322
}
312323
}
313324

314-
updateDom(*input, false);
325+
result.push_back(element);
315326
result.push_back(input);
316327
} else {
317-
DomElement *e = DomElement::getForUpdate(this, domElementType());
318-
updateDom(*e, false);
319-
result.push_back(e);
328+
updateDomElements(*element, *element, false);
329+
result.push_back(element);
320330
}
321331
}
322332

src/Wt/WCheckBox

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public:
110110
CheckState checkState() { return state_; }
111111

112112
protected:
113-
virtual void updateDom(DomElement& element, bool all);
113+
virtual void updateDomElements(DomElement& element, DomElement& input,
114+
bool all);
114115
virtual bool useImageWorkaround() const;
115116

116117
private:

src/Wt/WCheckBox.C

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ bool WCheckBox::needTristateImageWorkaround() const
8888
return !supportIndeterminate;
8989
}
9090

91-
void WCheckBox::updateDom(DomElement& element, bool all)
91+
void WCheckBox::updateDomElements(DomElement& element, DomElement& input,
92+
bool all)
9293
{
9394
if (all)
94-
element.setAttribute("type", "checkbox");
95+
input.setAttribute("type", "checkbox");
9596

96-
WAbstractToggleButton::updateDom(element, all);
97+
WAbstractToggleButton::updateDomElements(element, input, all);
9798
}
9899

99100
}

src/Wt/WRadioButton

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ private:
116116
friend class WButtonGroup;
117117

118118
protected:
119-
virtual void updateDom(DomElement& element, bool all);
119+
virtual void updateDomElements(DomElement& element, DomElement& input,
120+
bool all);
120121
virtual void getFormObjects(FormObjectsMap& formObjects);
121122

122123
virtual void setFormData(const FormData& formData);

src/Wt/WRadioButton.C

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ WRadioButton::~WRadioButton()
3434
buttonGroup_->removeButton(this);
3535
}
3636

37-
void WRadioButton::updateDom(DomElement& element, bool all)
37+
void WRadioButton::updateDomElements(DomElement& element, DomElement& input,
38+
bool all)
3839
{
3940
if (all) {
40-
element.setAttribute("type", "radio");
41+
input.setAttribute("type", "radio");
4142

4243
if (buttonGroup_) {
43-
element.setAttribute("name", buttonGroup_->id());
44-
element.setAttribute("value", id());
44+
input.setAttribute("name", buttonGroup_->id());
45+
input.setAttribute("value", id());
4546
}
4647
}
4748

48-
WAbstractToggleButton::updateDom(element, all);
49+
WAbstractToggleButton::updateDomElements(element, input, all);
4950
}
5051

5152
void WRadioButton::getFormObjects(FormObjectsMap& formObjects)

src/Wt/WServer

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ struct WServerImpl;
3030
*
3131
* As an example usage, consider the implementation of WRun(), which
3232
* starts the server until a Ctrl-C is pressed or a termination signal
33-
* has been received:
33+
* has been received, or a restart is indicated using SIGHUP or a changed
34+
* binary (argv[0]):
3435
*
3536
* \code
3637
int WRun(int argc, char *argv[], ApplicationCreator createApplication)
@@ -49,10 +50,13 @@ int WRun(int argc, char *argv[], ApplicationCreator createApplication)
4950
// by the server configuration's deploy-path)
5051
server.addEntryPoint(WServer::Application, createApplication);
5152
if (server.start()) {
52-
int sig = WServer::waitForShutdown();
53+
int sig = WServer::waitForShutdown(argv[0]);
5354
5455
std::cerr << "Shutdown (signal = " << sig << ")" << std::endl;
5556
server.stop();
57+
58+
if (sig == SIGHUP)
59+
WServer::restart(argc, argv, environ);
5660
}
5761
} catch (WServer::Exception& e) {
5862
std::cerr << e.what() << "\n";
@@ -197,14 +201,28 @@ public:
197201
*
198202
* This static method blocks the current thread, waiting for a
199203
* shutdown signal. The implementation and details are platform
200-
* dependent, but this is usually Ctrl-C or SIGKILL.
204+
* dependent, but this is usually Ctrl-C (SIGINT), SIGKILL, or
205+
* SIGHUP.
201206
*
202207
* This method is convenient if you want to customize how the server
203208
* is started (by instantiating a WServer object yourself, instead
204209
* of using Wt::Wrun()), but still want to use %Wt as a standalone
205210
* server that cleanly terminates on interruption.
211+
*
212+
* The optional \p restartWatchFile parameter can be used to let the
213+
* server watch for changes to a particular file (usually the binary
214+
* itself, argv[0]) which it will also interpret as SIGHUP. This may
215+
* be convenient to start the new binary after cleanly shutting down,
216+
* using restart(). <i>(Experimental, UNIX only)</i>
217+
*/
218+
static int waitForShutdown(const char *restartWatchFile = 0);
219+
220+
/*! \brief A utility method to restart.
221+
*
222+
* This will result the application with the new image (argv[0]), effectively
223+
* loading a newly deployed version. <i>(Experimental, UNIX only)</i>
206224
*/
207-
static int waitForShutdown();
225+
static void restart(int argc, char **argv, char **envp);
208226

209227
/*! \brief Returns whether the server is running.
210228
*

src/fcgi/Server.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void WServer::stop()
907907
}
908908
}
909909

910-
int WServer::waitForShutdown()
910+
int WServer::waitForShutdown(const char *restartWatchFile)
911911
{
912912
for (;;)
913913
sleep(10000);

0 commit comments

Comments
 (0)