Skip to content

Commit 1e4ed28

Browse files
committed
Several changes:
- Wt 4 specific: - Fixed regression introduced by adding msecsToHMS - Make sure that slots attached during signal emit are not executed immediately This fixes an issue where signals would loop infinitely, because the adding of a slot caused the same slot to be added again, etc. (modelReset() signal when calling e.g. clear() on a WStandardItemModel) - Merges from master: - Added a small clarification to WText intro about how invalid XHTML causes WText to switch to PlainText mode - CORS: only allow for WidgetSet, and allowed origins Introduced <allowed-origins> configuration option: - empty for no allowed origins - * for all - comma-separated list for exact matching - Added timeout handling to Postgres connections - fix dbo potential _unwind_resume problem with non-std::exception - make jwt resources-serving dependent on servlet version: v < 3: application server serves wt-resources v >= 3: servlet serves the wt-resources - fix ability to deploy same resource on multiple urls - added auxId() needed for e.g. sharding using Citus - Issue #5770: always render WAxisSliderWidget after WCartesianChart - Fix race condition related to detectDisconnect: Issue reported by Bruce Toll. We need to make sure to change disconnectCallback_ on the connection's strand, and we don't need an extra buffer to detect disconnect. Added test case written by Bruce Toll to check this race condition. - Handling NaN in maxZoom(), possible if using an empty series - Implement missing modelReset() in proxy models Issue raised by PR emweb#118 on GitHub.
1 parent fef7330 commit 1e4ed28

Some content is hidden

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

45 files changed

+806
-120
lines changed

src/Wt/Chart/WAxis.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,10 @@ double WAxis::maxZoom() const
12821282
double min = drawnMinimum();
12831283
double max = drawnMaximum();
12841284
double zoom = (max - min) / minimumZoomRange();
1285-
if (zoom < 1.0)
1285+
if (zoom < 1.0 || zoom != zoom)
12861286
return 1.0;
12871287
else
1288-
return (max - min) / minimumZoomRange();
1288+
return zoom;
12891289
}
12901290

12911291
void WAxis::setMinimumZoomRange(double size)

src/Wt/Chart/WAxisSliderWidget.C

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,14 @@ WTransform WAxisSliderWidget::hv(const WTransform& t) const
213213

214214
void WAxisSliderWidget::paintEvent(WPaintDevice *paintDevice)
215215
{
216-
// Don't paint anything, unless we're associated to a chart,
217-
// and the chart has been painted.
218-
if (chart() && !chart()->cObjCreated_) {
219-
return;
220-
}
221216
if (!chart()) {
222217
LOG_ERROR("Attempted to draw a slider widget not associated with a chart.");
223218
return;
224219
}
220+
// Don't paint anything, unless we're associated to a chart,
221+
// and the chart has been painted.
222+
if (!chart()->cObjCreated_ || chart()->needRerender())
223+
return;
225224

226225
if (series_->type() != SeriesType::Line &&
227226
series_->type() != SeriesType::Curve) {

src/Wt/Chart/WCartesianChart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,8 @@ private:
12901290

12911291
static WColor lightenColor(const WColor &in);
12921292

1293+
virtual void getDomChanges(std::vector<DomElement *>& result, WApplication *app) override;
1294+
12931295
protected:
12941296
virtual void modelChanged() override;
12951297
virtual void modelReset() override;

src/Wt/Chart/WCartesianChart.C

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,10 +2383,14 @@ void WCartesianChart::paintEvent(WPaintDevice *paintDevice)
23832383
doJavaScript(ss.str());
23842384

23852385
cObjCreated_ = true;
2386+
}
2387+
}
23862388

2387-
for (std::size_t i = 0; i < axisSliderWidgets_.size(); ++i) {
2388-
axisSliderWidgets_[i]->update();
2389-
}
2389+
void WCartesianChart::getDomChanges(std::vector<DomElement *>& result, WApplication *app)
2390+
{
2391+
WAbstractChart::getDomChanges(result, app);
2392+
for (std::size_t i = 0; i < axisSliderWidgets_.size(); ++i) {
2393+
axisSliderWidgets_[i]->update();
23902394
}
23912395
}
23922396

src/Wt/Dbo/DbAction

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private:
6161

6262
bool idField_;
6363
std::string foreignKeyTable_, foreignKeyName_;
64-
int fkConstraints_;
64+
int fkConstraints_, fkFlags_;
6565
};
6666

6767
class WTDBO_API DropSchema
@@ -174,14 +174,19 @@ public:
174174
* to simply bind values to a statement using field().
175175
*/
176176
SaveBaseAction(Session *session, SqlStatement *statement, int column);
177-
177+
178178
SaveBaseAction(MetaDboBase& dbo, Impl::MappingInfo& mapping,
179179
SqlStatement *statement = nullptr, int column = 0);
180180

181181
template<typename V> void act(const FieldRef<V>& field);
182182
template<class C> void actPtr(const PtrRef<C>& field);
183183
template<class C> void actWeakPtr(const WeakPtrRef<C>& field);
184184
template<class C> void actCollection(const CollectionRef<C>& field);
185+
template<typename V> void actId(V& value, const std::string& name, int size);
186+
template<class D> void actId(ptr<D>& value, const std::string& name, int size,
187+
int fkConstraints);
188+
189+
template<class C> void visitAuxIds(C& obj);
185190

186191
bool getsValue() const;
187192

@@ -192,6 +197,7 @@ protected:
192197
bool isInsert_;
193198
int column_;
194199
bool bindNull_;
200+
bool auxIdOnly_;
195201

196202
enum { Dependencies, Self, Sets } pass_;
197203
bool needSetsPass_;
@@ -358,6 +364,9 @@ struct action_sets_value<FromAnyAction> : std::true_type { };
358364
template<typename V>
359365
void SaveBaseAction::act(const FieldRef<V>& field)
360366
{
367+
if (auxIdOnly_ && !(field.flags() & FieldRef<V>::AuxId))
368+
return;
369+
361370
if (pass_ == Self) {
362371
if (bindNull_)
363372
statement_->bindNull(column_++);

src/Wt/Dbo/DbAction.C

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ namespace Wt {
3232
InitSchema::InitSchema(Session& session, Impl::MappingInfo& mapping)
3333
: session_(session),
3434
mapping_(mapping),
35-
idField_(false)
35+
idField_(false),
36+
fkFlags_(0)
3637
{ }
3738

3839
void InitSchema::actMapping(Impl::MappingInfo *mapping)
@@ -125,7 +126,8 @@ SaveBaseAction::SaveBaseAction(Session *session, SqlStatement *statement,
125126
: DboAction(session),
126127
statement_(statement),
127128
column_(column),
128-
bindNull_(false)
129+
bindNull_(false),
130+
auxIdOnly_(false)
129131
{
130132
pass_ = Self;
131133
}
@@ -135,7 +137,8 @@ SaveBaseAction::SaveBaseAction(MetaDboBase& dbo, Impl::MappingInfo& mapping,
135137
: DboAction(dbo, mapping),
136138
statement_(statement),
137139
column_(column),
138-
bindNull_(false)
140+
bindNull_(false),
141+
auxIdOnly_(false)
139142
{
140143
pass_ = Self;
141144
}

src/Wt/Dbo/DbAction_impl.h

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ void InitSchema::act(const FieldRef<V>& field)
8181
if (idField_)
8282
flags |= FieldFlags::NaturalId; // Natural id
8383

84+
if ((field.flags() & FieldRef<V>::AuxId) || (fkFlags_ & PtrRef<V>::AuxId))
85+
flags |= FieldFlags::AuxId; // Aux id (appended in update and delete)
86+
8487
if (!foreignKeyName_.empty())
8588
// Foreign key
8689
mapping_.fields.push_back
@@ -104,6 +107,7 @@ void InitSchema::actPtr(const PtrRef<C>& field)
104107
foreignKeyName_ = field.name();
105108
foreignKeyTable_ = mapping->tableName;
106109
fkConstraints_ = field.fkConstraints();
110+
fkFlags_ = field.flags();
107111
}
108112

109113
field.visit(*this, &session_);
@@ -112,6 +116,7 @@ void InitSchema::actPtr(const PtrRef<C>& field)
112116
foreignKeyName_.clear();
113117
foreignKeyTable_.clear();
114118
fkConstraints_ = 0;
119+
fkFlags_ = 0;
115120
}
116121
}
117122

@@ -334,6 +339,28 @@ void LoadDbAction<C>::actId(ptr<D>& value, const std::string& name, int size,
334339
* SaveDbAction
335340
*/
336341

342+
template <class C>
343+
void SaveBaseAction::visitAuxIds(C& obj)
344+
{
345+
auxIdOnly_ = true;
346+
pass_ = Self;
347+
348+
persist<C>::apply(obj, *this);
349+
}
350+
351+
template<typename V>
352+
void SaveBaseAction::actId(V& value, const std::string& name, int size)
353+
{
354+
/* Only used from within visitAuxIds() */
355+
}
356+
357+
template<class D>
358+
void SaveBaseAction::actId(ptr<D>& value, const std::string& name, int size,
359+
int fkConstraints)
360+
{
361+
/* Only used from within visitAuxIds() */
362+
}
363+
337364
template<class C>
338365
void SaveBaseAction::actPtr(const PtrRef<C>& field)
339366
{
@@ -347,10 +374,18 @@ void SaveBaseAction::actPtr(const PtrRef<C>& field)
347374

348375
break;
349376
case Self:
350-
bindNull_ = !field.value();
351-
field.visit(*this, session());
352-
bindNull_ = false;
377+
if (auxIdOnly_ && !(field.flags() & PtrRef<C>::AuxId))
378+
return;
353379

380+
{
381+
bool wasAuxIdOnly = auxIdOnly_;
382+
auxIdOnly_ = false;
383+
bindNull_ = !field.value();
384+
field.visit(*this, session());
385+
bindNull_ = false;
386+
auxIdOnly_ = wasAuxIdOnly;
387+
}
388+
354389
break;
355390
case Sets:
356391
break;
@@ -360,6 +395,9 @@ void SaveBaseAction::actPtr(const PtrRef<C>& field)
360395
template<class C>
361396
void SaveBaseAction::actWeakPtr(const WeakPtrRef<C>& field)
362397
{
398+
if (auxIdOnly_)
399+
return;
400+
363401
switch (pass_) {
364402
case Dependencies:
365403
break;
@@ -377,6 +415,9 @@ void SaveBaseAction::actWeakPtr(const WeakPtrRef<C>& field)
377415
template<class C>
378416
void SaveBaseAction::actCollection(const CollectionRef<C>& field)
379417
{
418+
if (auxIdOnly_)
419+
return;
420+
380421
switch (pass_) {
381422
case Dependencies:
382423
break;
@@ -499,7 +540,7 @@ void SaveDbAction<C>::visit(C& obj)
499540

500541
if (!isInsert_) {
501542
MetaDboBase *dbo = dynamic_cast<MetaDboBase *>(&dbo_);
502-
dbo->bindId(statement_, column_);
543+
dbo->bindModifyId(statement_, column_);
503544

504545
if (mapping().versionFieldName) {
505546
// when saved in the transaction, we will be at version() + 1

src/Wt/Dbo/Field

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,15 @@ template <typename V>
142142
class FieldRef
143143
{
144144
public:
145-
FieldRef(V& value, const std::string& name, int size);
145+
enum Flag {
146+
AuxId = 0x1
147+
};
148+
149+
FieldRef(V& value, const std::string& name, int size, int flags = 0);
146150

147151
const std::string& name() const;
148152
int size() const;
153+
int flags() const;
149154

150155
std::string sqlType(Session& session) const;
151156
const std::type_info *type() const;
@@ -159,6 +164,7 @@ private:
159164
V& value_;
160165
std::string name_;
161166
int size_;
167+
int flags_;
162168
};
163169

164170
/*! \brief Type of an SQL relation.
@@ -197,11 +203,16 @@ template <class C>
197203
class PtrRef
198204
{
199205
public:
200-
PtrRef(ptr<C>& value, const std::string& name, int fkConstraints);
206+
enum Flag {
207+
AuxId = 0x1
208+
};
209+
210+
PtrRef(ptr<C>& value, const std::string& name, int fkConstraints, int flags = 0);
201211

202212
const std::string& name() const { return name_; }
203213
bool literalForeignKey() const { return literalForeignKey_; }
204214
int fkConstraints() const { return fkConstraints_; }
215+
int flags() const { return flags_; }
205216
ptr<C>& value() const { return value_; }
206217
typename dbo_traits<C>::IdType id() const { return value_.id(); }
207218

@@ -218,6 +229,7 @@ private:
218229
std::string name_;
219230
bool literalForeignKey_;
220231
int fkConstraints_;
232+
int flags_;
221233
};
222234

223235
template <class C>
@@ -269,6 +281,15 @@ template <class Action, class C>
269281
void id(Action& action, ptr<C>& value, const std::string& name,
270282
ForeignKeyConstraint constraints, int size = -1);
271283

284+
template <class Action, typename V>
285+
void auxId(Action& action, V& value, const std::string& name,
286+
int size = -1);
287+
288+
template <class Action, class C>
289+
void auxId(Action& action, ptr<C>& value, const std::string& name,
290+
ForeignKeyConstraint constraint = ForeignKeyConstraint(0), int size = -1);
291+
292+
272293
/*! \brief Maps a database object field.
273294
*
274295
* This function binds the field \p value to the database field \p name.

src/Wt/Dbo/Field_impl.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ namespace Wt {
1717
namespace Dbo {
1818

1919
template <typename V>
20-
FieldRef<V>::FieldRef(V& value, const std::string& name, int size)
20+
FieldRef<V>::FieldRef(V& value, const std::string& name, int size, int flags)
2121
: value_(value),
2222
name_(name),
23-
size_(size)
23+
size_(size),
24+
flags_(flags)
2425
{ }
2526

2627
template <typename V>
@@ -35,6 +36,12 @@ int FieldRef<V>::size() const
3536
return size_;
3637
}
3738

39+
template <typename V>
40+
int FieldRef<V>::flags() const
41+
{
42+
return flags_;
43+
}
44+
3845
template <typename V>
3946
std::string FieldRef<V>::sqlType(Session& session) const
4047
{
@@ -81,11 +88,12 @@ CollectionRef<C>::CollectionRef(collection< ptr<C> >& value,
8188

8289
template <class C>
8390
PtrRef<C>::PtrRef(ptr<C>& value, const std::string& name,
84-
int fkConstraints)
91+
int fkConstraints, int flags)
8592
: value_(value),
8693
name_(name),
8794
literalForeignKey_(false),
88-
fkConstraints_(fkConstraints)
95+
fkConstraints_(fkConstraints),
96+
flags_(flags)
8997
{
9098
if (!name.empty() && name[0] == '>') {
9199
name_ = std::string(name.c_str() + 1, name.size() - 1);
@@ -176,6 +184,20 @@ void id(A& action, ptr<C>& value, const std::string& name,
176184
action.actId(value, name, size, constraint.value());
177185
}
178186

187+
template <class Action, typename V>
188+
void auxId(Action& action, V& value, const std::string& name,
189+
int size)
190+
{
191+
action.act(FieldRef<V>(value, name, size, FieldRef<V>::AuxId));
192+
}
193+
194+
template <class Action, class C>
195+
void auxId(Action& action, ptr<C>& value, const std::string& name,
196+
ForeignKeyConstraint constraint, int size)
197+
{
198+
action.actPtr(PtrRef<C>(value, name, constraint.value(), PtrRef<C>::AuxId));
199+
}
200+
179201
template <class A, typename V>
180202
void field(A& action, V& value, const std::string& name, int size)
181203
{

src/Wt/Dbo/QueryModel_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ void QueryModel<Result>::cacheRow(int row) const
286286

287287
Transaction transaction(query_.session());
288288

289+
std::cerr << "Fetching offset=" << qOffset << ", limit=" << qLimit << std::endl;
289290
collection<Result> results = query_.resultList();
290291
cache_.clear();
291292
cache_.insert(cache_.end(), results.begin(), results.end());

0 commit comments

Comments
 (0)