Skip to content

Commit be43c1c

Browse files
author
Koen Deforche
committed
Bug fixes and small improvements:
- http/Connection: fix a leak in websocket sockets (file descriptors) - WLayout: added a clear() method which removes all contents - WDataSeries: fix setLabelColor() being ignored - Dbo/backend/Postgres: set client encoding to UTF8 - WTable: added moveRow() and moveColumn() methods - WTableView: fix setColumnHidden() with headerColumns() - WebSession: use baseURL property for self-referencing URLs
1 parent b8ab3b6 commit be43c1c

28 files changed

+351
-199
lines changed

Changelog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
26-04-2011:
2+
* http/Connection: fix a leak in websocket sockets (file descriptors)
3+
4+
* WLayout: added a clear() method which removes all contents
5+
6+
* WDataSeries: fix setLabelColor() being ignored
7+
8+
* Dbo/backend/Postgres: set client encoding to UTF8
9+
10+
* WTable: added moveRow() and moveColumn() methods
11+
12+
* WTableView: fix setColumnHidden() with headerColumns()
13+
14+
* WebSession: use baseURL property for self-referencing URLs
15+
116
14-04-2011:
217
* WAbstractArea: fix anchor not being deleted
318

src/Wt/Chart/WDataSeries.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ WColor WDataSeries::labelColor() const
130130
void WDataSeries::setLabelColor(const WColor& color)
131131
{
132132
set(labelColor_, color);
133+
134+
customFlags_ |= CustomLabelColor;
133135
}
134136

135137
void WDataSeries::setFillRange(FillRangeType fillRange)

src/Wt/Dbo/backend/Postgres.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ bool Postgres::connect(const std::string& db)
542542
throw PostgresException("Could not connect to: " + error);
543543
}
544544

545+
PQsetClientEncoding(conn_, "UTF8");
546+
545547
return true;
546548
}
547549

src/Wt/WLayout

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ public:
165165
int getContentsMargin(Side side) const;
166166
#endif // WT_TARGET_JAVA
167167

168+
/*! \brief Removes and deletes all child widgets and nested layouts.
169+
*
170+
* This is similar to WContainerWidget::clear(), with the exception that
171+
* the layout itself is not deleted.
172+
*/
173+
virtual void clear();
174+
168175
protected:
169176
/*! \brief Create a layout.
170177
*/

src/Wt/WLayout.C

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include "WtException.h"
1313

14+
#include <set>
15+
1416
namespace Wt {
1517

1618
WLayout::WLayout()
@@ -185,7 +187,7 @@ void WLayout::setParentLayout(WLayout *layout)
185187
if (layout)
186188
layout->addChild(this);
187189
else
188-
setParent(0);
190+
parent()->removeChild(this);
189191
}
190192

191193
WLayout *WLayout::parentLayout() const
@@ -204,4 +206,25 @@ void WLayout::setLayoutHint(const std::string& name, const std::string& value)
204206
}
205207
}
206208

209+
void WLayout::clear()
210+
{
211+
while (count()) {
212+
WLayoutItem *item = itemAt(count() - 1);
213+
214+
if (item) {
215+
WWidget* widget = 0;
216+
217+
if (item->layout())
218+
item->layout()->clear();
219+
else
220+
widget = item->widget();
221+
222+
removeItem(item);
223+
delete item;
224+
225+
delete widget;
226+
}
227+
}
228+
}
229+
207230
}

src/Wt/WTable

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ public:
154154
*/
155155
int headerCount(Orientation orientation = Horizontal);
156156

157+
/*! \brief Move a table row from its original position to a new position.
158+
*
159+
* The table expands automatically when to is beyond the current
160+
* table dimensions.
161+
*
162+
* \sa moveColumn()
163+
*/
164+
void moveRow(int from, int to);
165+
166+
/*! \brief Move a table column from its original position to a new position.
167+
*
168+
* The table expands automatically when to is beyond the current
169+
* table dimensions.
170+
*
171+
* \sa moveRow()
172+
*/
173+
void moveColumn(int from, int to);
174+
157175
private:
158176
static const int BIT_GRID_CHANGED = 0;
159177
static const int BIT_COLUMNS_CHANGED = 1;

src/Wt/WTable.C

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "Wt/WEnvironment"
1111
#include "Wt/WTable"
1212
#include "Wt/WTableCell"
13+
#include "Wt/WTableRow"
1314
#include "DomElement.h"
15+
#include "Utils.h"
1416

1517
namespace Wt {
1618

@@ -401,4 +403,45 @@ WTableRow::TableData& WTable::itemAt(int row, int column)
401403
return rows_[row]->cells_[column];
402404
}
403405

406+
void WTable::moveRow(int from, int to)
407+
{
408+
if (from < 0 || from >= (int)rows_.size())
409+
throw std::logic_error("WTable::moveRow: the from index is not within the "
410+
"current table dimensions.");
411+
412+
WTableRow* from_tr = rowAt(from);
413+
414+
Utils::erase(rows_, from_tr);
415+
if (to > (int)rows_.size())
416+
rowAt(to);
417+
rows_.insert(rows_.begin() + to, from_tr);
418+
419+
flags_.set(BIT_GRID_CHANGED);
420+
repaint(RepaintInnerHtml);
421+
}
422+
423+
void WTable::moveColumn(int from, int to)
424+
{
425+
if (from < 0 || from >= (int)columns_.size())
426+
throw std::logic_error("WTable::moveColumn: the from index is not within "
427+
"the current table dimensions.");
428+
429+
WTableColumn* from_tc = columnAt(from);
430+
431+
Utils::erase(columns_, from_tc);
432+
if (to > (int)columns_.size())
433+
columnAt(to);
434+
columns_.insert(columns_.begin() + to, from_tc);
435+
436+
for (unsigned i = 0; i < rows_.size(); i++) {
437+
std::vector<WTableRow::TableData>& cells = rows_[i]->cells_;
438+
WTableRow::TableData cell = cells[from];
439+
cells.erase(cells.begin() + from);
440+
cells.insert(cells.begin() + to, cell);
441+
}
442+
443+
flags_.set(BIT_GRID_CHANGED);
444+
repaint(RepaintInnerHtml);
445+
}
446+
404447
}

src/Wt/WTableView.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,8 @@ void WTableView::setColumnHidden(int column, bool hidden)
831831
if (renderState_ >= NeedRerenderHeader)
832832
return;
833833

834-
WWidget *hc = headers_->widget(column);
834+
WWidget *hc = headerWidget(column);
835+
835836
if (!ajaxMode())
836837
hc->parent()->setHidden(hidden);
837838
else

src/Wt/WText.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ void WText::render(WFlags<RenderFlag> flags)
214214
{
215215
if (textChanged_)
216216
autoAdjustInline();
217+
218+
WInteractWidget::render(flags);
217219
}
218220

219221
void WText::refresh()

src/Wt/WWebWidget.C

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,14 @@ void WWebWidget::setJavaScriptMember(const std::string& name,
843843
else
844844
return;
845845
} else {
846-
OtherImpl::Member m;
847-
m.name = name;
848-
m.value = value;
849-
members.push_back(m);
846+
if (index == -1) {
847+
OtherImpl::Member m;
848+
m.name = name;
849+
m.value = value;
850+
members.push_back(m);
851+
} else {
852+
members[index].value = value;
853+
}
850854
}
851855

852856
if (!otherImpl_->jsMembersSet_)

0 commit comments

Comments
 (0)