Skip to content

Commit 267c72d

Browse files
author
Koen Deforche
committed
a batch of Wt::Dbo fixes and improvements, and other fixes (for IE9, misc bugs)
1 parent bb96acb commit 267c72d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+460
-132
lines changed

examples/painting/PaintExample.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ PaintExample::PaintExample(WContainerWidget *root, bool showTitle)
7373
shapes_ = new ShapesWidget();
7474
shapes_->setAngle(0.0);
7575
shapes_->setRelativeSize(0.5);
76-
shapes_->setPreferredMethod(WPaintedWidget::InlineSvgVml);
76+
shapes_->setPreferredMethod(WPaintedWidget::HtmlCanvas);
7777

7878
layout->addWidget(shapes_, 1, 1, AlignCenter | AlignMiddle);
7979
}

examples/wt-homepage/wt-home.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ target="_blank">nice introduction to Wt</a> written by Victor Venkman.</p>
490490
set. For Ajax sessions, they support <b>pre-loading</b> and <b>lazy
491491
loading</b> of the contents associated with each item. Pre-loaded
492492
contents does not increase the load time because the Wt rendering
493-
engine oalways ptimizes the response time by only transmitting
493+
engine always optimizes the response time by only transmitting
494494
visual widgets or changes first. Everything invisible (such as the
495495
contents for other pre-loaded menu items) is transmitted in the
496496
background, after rendering the visible contents.

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ web/WebSession.C
287287
web/WebSocketMessage.C
288288
web/WebRenderer.C
289289
web/WebUtils.C
290+
web/FileUtils.C
290291
web/TimeUtil.C
291292
web/XSSFilter.C
292293
web/XSSUtils.C

src/Wt/Chart/WChart2DRenderer.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ public:
330330
it_.currentYSegment()).x(),
331331
renderer_.chartArea().top());
332332
break;
333+
default:
334+
break;
333335
}
334336

335337
double g = numGroups_ + (numGroups_ - 1) * renderer_.chart()->barMargin();

src/Wt/Dbo/Call.C

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ Call::Call(const Call& other)
2222

2323
void Call::run()
2424
{
25-
statement_->execute();
26-
statement_->done();
25+
try {
26+
run_ = true;
27+
statement_->execute();
28+
statement_->done();
29+
} catch (...) {
30+
statement_->done();
31+
throw;
32+
}
2733
}
2834

2935
Call::Call(Session& session, const std::string& sql)

src/Wt/Dbo/SqlTraits

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class SqlStatement;
3939
* - <tt>std::vector<unsigned char></tt> (binary data)
4040
* - <tt>boost::optional<T></tt>: to make the type optional
4141
* (allowing an SQL <tt>null</tt> value)
42+
* - <tt>boost::posix_time::ptime</tt>: time stamp, an invalid value (e.g.
43+
* default constructed), maps to <tt>null</tt>
44+
* - <tt>boost::posix_time::time_duration</tt>: time interval, an invalid
45+
* value (boost::posix_time::not_a_date_time), maps to <tt>null</tt>
4246
*
4347
* In <Wt/Dbo/WtSqlTraits>, traits classes are also provided for:
4448
* - WDate

src/Wt/Dbo/StdSqlTraits

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <Wt/Dbo/SqlStatement>
1414

1515
#include <boost/optional.hpp>
16+
#include <boost/date_time/posix_time/posix_time.hpp>
1617
#include <boost/utility/enable_if.hpp>
1718
#include <boost/type_traits/is_enum.hpp>
1819

@@ -101,6 +102,30 @@ struct WTDBO_API sql_value_traits<double, void>
101102
static bool read(double& v, SqlStatement *statement, int column, int size);
102103
};
103104

105+
template<>
106+
struct WTDBO_API sql_value_traits<boost::posix_time::ptime, void>
107+
{
108+
static const bool specialized = true;
109+
110+
static const char *type(SqlConnection *conn, int size);
111+
static void bind(const boost::posix_time::ptime& v, SqlStatement *statement,
112+
int column, int size);
113+
static bool read(boost::posix_time::ptime& v, SqlStatement *statement,
114+
int column, int size);
115+
};
116+
117+
template<>
118+
struct WTDBO_API sql_value_traits<boost::posix_time::time_duration, void>
119+
{
120+
static const bool specialized = true;
121+
122+
static const char *type(SqlConnection *conn, int size);
123+
static void bind(const boost::posix_time::time_duration& v,
124+
SqlStatement *statement, int column, int size);
125+
static bool read(boost::posix_time::time_duration& v,
126+
SqlStatement *statement, int column, int size);
127+
};
128+
104129
template <typename Enum>
105130
struct WTDBO_API sql_value_traits<Enum,
106131
typename boost::enable_if<boost::is_enum<Enum> >::type>

src/Wt/Dbo/StdSqlTraits.C

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,73 @@ bool sql_value_traits<double>::read(double& v, SqlStatement *statement,
218218
}
219219

220220
/*
221-
* std::vector<unsigned char>
221+
* boost::posix_time::ptime
222222
*/
223223

224+
const char *sql_value_traits<boost::posix_time::ptime>
225+
::type(SqlConnection *conn, int size)
226+
{
227+
return conn->dateTimeType(SqlDateTime);
228+
}
229+
230+
void sql_value_traits<boost::posix_time::ptime>
231+
::bind(const boost::posix_time::ptime& v, SqlStatement *statement,
232+
int column, int size)
233+
{
234+
if (v.is_special())
235+
statement->bindNull(column);
236+
else
237+
statement->bind(column, v, SqlDateTime);
238+
}
239+
240+
bool sql_value_traits<boost::posix_time::ptime>
241+
::read(boost::posix_time::ptime& v, SqlStatement *statement, int column,
242+
int size)
243+
{
244+
if (statement->getResult(column, &v, SqlDateTime))
245+
return true;
246+
else {
247+
v = boost::posix_time::ptime();
248+
return false;
249+
}
250+
}
251+
252+
/*
253+
* boost::posix_time::time_duration
254+
*/
255+
256+
const char *sql_value_traits<boost::posix_time::time_duration>
257+
::type(SqlConnection *conn, int size)
258+
{
259+
return conn->dateTimeType(SqlTime);
260+
}
261+
262+
void sql_value_traits<boost::posix_time::time_duration>
263+
::bind(const boost::posix_time::time_duration& v, SqlStatement *statement,
264+
int column, int size)
265+
{
266+
if (v.is_special())
267+
statement->bindNull(column);
268+
else
269+
statement->bind(column, v);
270+
}
271+
272+
bool sql_value_traits<boost::posix_time::time_duration>
273+
::read(boost::posix_time::time_duration& v, SqlStatement *statement,
274+
int column, int size)
275+
{
276+
if (statement->getResult(column, &v))
277+
return true;
278+
else {
279+
v = boost::posix_time::time_duration(boost::posix_time::not_a_date_time);
280+
return false;
281+
}
282+
}
283+
284+
/*
285+
* std::vector<unsigned char>
286+
*/
287+
224288
const char *sql_value_traits<std::vector<unsigned char> >
225289
::type(SqlConnection *conn, int size)
226290
{

src/Wt/Dbo/WtSqlTraits

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ struct sql_value_traits<WTime, void>
5353
static const char *format;
5454

5555
static const char *type(SqlConnection *conn, int size);
56-
static void bind(const WTime& v, SqlStatement *statement, int column, int size);
56+
static void bind(const WTime& v, SqlStatement *statement, int column,
57+
int size);
5758
static bool read(WTime& v, SqlStatement *statement, int column, int size);
5859
};
5960

src/Wt/Dbo/ptr_impl.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ ptr<C>& ptr<C>::operator= (const ptr<C>& other)
285285
template <class C>
286286
const C *ptr<C>::operator->() const
287287
{
288-
return get();
288+
const C *v = get();
289+
290+
if (!v)
291+
throw Exception("Wt::Dbo::ptr: null dereference");
292+
293+
return v;
289294
}
290295

291296
template <class C>
@@ -303,7 +308,7 @@ const C& ptr<C>::operator*() const
303308
if (obj_)
304309
return *obj_->obj();
305310
else
306-
throw Exception("ptr: null dereference");
311+
throw Exception("Wt::Dbo::ptr: null dereference");
307312
}
308313

309314
template <class C>
@@ -312,7 +317,7 @@ typename ptr<C>::mutator ptr<C>::modify() const
312317
if (obj_)
313318
return mutator(obj_);
314319
else
315-
throw Exception("ptr: null dereference");
320+
throw Exception("Wt::Dbo::ptr: null dereference");
316321
}
317322

318323
template <class C>

0 commit comments

Comments
 (0)