Skip to content

Commit 9c38a29

Browse files
author
Koen Deforche
committed
fix std::round nonportability
1 parent 2e42bfd commit 9c38a29

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Wt/WTableView.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define CONTENTS_VIEWPORT_HEIGHT -1
2727

2828
#include <cmath>
29+
#include <math.h>
2930

3031
namespace Wt {
3132

@@ -906,7 +907,7 @@ void WTableView::setColumnHidden(int column, bool hidden)
906907

907908
void WTableView::setColumnWidth(int column, const WLength& width)
908909
{
909-
WLength rWidth = WLength(std::round(width.value()), width.unit());
910+
WLength rWidth = WLength(round(width.value()), width.unit());
910911
double delta = rWidth.toPixels() - columnInfo(column).width.toPixels();
911912
columnInfo(column).width = rWidth;
912913

src/Wt/WTreeView.C

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* See the LICENSE file for terms of use.
55
*/
66

7+
#include <math.h>
78
#include <cmath>
89
#include <iostream>
910
#include <boost/lexical_cast.hpp>
@@ -1184,11 +1185,14 @@ WT_USTRING WTreeView::columnFormat(int column) const
11841185

11851186
void WTreeView::setColumnWidth(int column, const WLength& width)
11861187
{
1187-
columnInfo(column).width = width;
1188+
if (!width.isAuto())
1189+
columnInfo(column).width = WLength(round(width.value()), width.unit());
1190+
else
1191+
columnInfo(column).width = WLength::Auto;
11881192

11891193
WWidget *toResize = columnInfo(column).styleRule->templateWidget();
11901194
toResize->setWidth(0);
1191-
toResize->setWidth(width.toPixels());
1195+
toResize->setWidth(columnInfo(column).width.toPixels());
11921196

11931197
WApplication *app = WApplication::instance();
11941198

0 commit comments

Comments
 (0)