Skip to content

Commit

Permalink
Add a fix from Wt 3
Browse files Browse the repository at this point in the history
If WTimer outlives timerRoot_, this would cause a segfault, so a WTimer
could not reliably be the child of WApplication.
  • Loading branch information
RockinRoel committed Jul 23, 2020
1 parent 1141a15 commit 9d6392d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Wt/WApplication.C
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@ std::string WApplication::onePixelGifUrl()
WApplication::~WApplication()
{
#ifndef WT_TARGET_JAVA
// Fix issue #5331: if WTimer is a child of WApplication,
// it will outlive timerRoot_. Delete it now already.
for (std::size_t i = 0; i < children_.size(); ++i) {
WTimer *timer = dynamic_cast<WTimer*>(children_[i].get());
if (timer) {
removeChild(timer);
}
}
timerRoot_ = nullptr;

// First remove all children owned by this WApplication (issue #6282)
if (domRoot_) {
auto domRoot = domRoot_.get();
Expand Down
1 change: 1 addition & 0 deletions src/Wt/WObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class WT_API WObject : public Wt::Core::observable
static unsigned nextObjId_;

friend class EventSignalBase;
friend class WApplication;
friend class WebSession;
};

Expand Down

0 comments on commit 9d6392d

Please sign in to comment.