Skip to content

Commit

Permalink
Several changes:
Browse files Browse the repository at this point in the history
 - Fix #5843: Make sure zIndex is higher than any sibling with same or lower baseZIndex,
   and at least equal to baseZIndex
 - Add virtual destructor to Session/Transaction, make sure they're not copyable/movable
 - Issue #5841: allow MySQL operation to continue when connection lost
   Also, err_nb == CR_SERVER_LOST can also occur, apparently.
   return statement after connect allows action to continue.
 - src/Wt/Dbo/backend/Postgres.C: That type of for loop is a C++11 feature
 - Added unwind support to release notes
  • Loading branch information
RockinRoel committed Jul 31, 2017
1 parent 9b7bce4 commit bae7dc7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
1 change: 1 addition & 0 deletions ReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ <h2>Release 3.3.8 (July 2017)</h2>
RESTful services is planned in a future release.</li>
<li>Added <a href="classWt_1_1Dbo_1_1FixedSqlConnectionPool.html#a955e2ce03d8d45e8738f6ff718614601">Wt::Dbo::FixedSqlConnectionPool::setTimeout()</a>, to set a timeout for obtaining a connection.</li>
<li>Added <a href="classWt_1_1Dbo_1_1backend_1_1Postgres.html#acb13461474cc43bc9e8a51b844a051f3">Wt::Dbo::backend::Postgres::setTimeout()</a>, to set a timeout for queries.</li>
<li>Added libunwind support for printing stacktraces. Enable this with the <tt>ENABLE_UNWIND</tt> CMake option.</li>
</ul>
</dd>
</dl>
Expand Down
18 changes: 16 additions & 2 deletions src/Wt/Dbo/Session
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,17 @@ public:
* through it, and will warning during this destructor if there are
* still database objects that are being referenced from a ptr.
*/
~Session();
virtual ~Session();

#ifdef WT_CXX11
// Sessions are not copyable
Session(const Session &) = delete;
Session& operator=(const Session &) = delete;

// Sessions are not movable
Session(Session &&) = delete;
Session& operator=(Session &&) = delete;
#endif // WT_CXX11

/*! \brief Sets a dedicated connection.
*
Expand Down Expand Up @@ -483,11 +493,15 @@ public:
void setFlushMode(FlushMode mode) { flush(); flushMode_ = mode; }

private:

mutable std::string longlongType_;
mutable std::string intType_;
mutable bool haveSupportUpdateCascade_;

#ifndef WT_CXX11
// Sessions are not copyable
Session(const Session& s);
Session& operator=(const Session& s);
#endif // WT_CXX11

typedef boost::multi_index::multi_index_container<
MetaDboBase *,
Expand Down
18 changes: 17 additions & 1 deletion src/Wt/Dbo/Transaction
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,17 @@ public:
*
* If the transaction is still active, it is rolled back.
*/
~Transaction() WT_CXX11ONLY(noexcept(false));
virtual ~Transaction() WT_CXX11ONLY(noexcept(false));

#ifdef WT_CXX11
// Transactions are not copyable
Transaction(const Transaction&) = delete;
Transaction& operator=(const Transaction&) = delete;

// Transactions are not movable
Transaction(Transaction&&) = delete;
Transaction& operator=(Transaction&&) = delete;
#endif // WT_CXX11

/*! \brief Returns whether the transaction is still active.
*
Expand Down Expand Up @@ -126,6 +136,12 @@ public:
SqlConnection *connection() const;

private:
#ifndef WT_CXX11
// Transactions should not be copied
Transaction(const Transaction& other);
Transaction& operator=(const Transaction& other);
#endif // WT_CXX11

struct Impl {
Session& session_;
bool active_;
Expand Down
4 changes: 3 additions & 1 deletion src/Wt/Dbo/backend/MySQL.C
Original file line number Diff line number Diff line change
Expand Up @@ -994,12 +994,14 @@ void MySQL::checkConnection()
err_nb = mysql_errno(impl_->mysql);
err = std::string(mysql_error(impl_->mysql));
}
if (err_nb == CR_SERVER_GONE_ERROR) {
if (err_nb == CR_SERVER_GONE_ERROR ||
err_nb == CR_SERVER_LOST) {
clearStatementCache();
mysql_close(impl_->mysql);
impl_->mysql = 0;
try {
connect(dbname_, dbuser_, dbpasswd_, dbhost_, dbport_, dbsocket_);
return;
} catch (MySQLException e) {
throw MySQLException("checkConnection: Error when reconnecting: " + std::string(e.what()));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Wt/Dbo/backend/Postgres.C
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ void Postgres::disconnect()
/* Evict also the statements -- the statements themselves can stay,
only running statements behavior is affected (but we are dealing with
that while calling disconnect) */
for (auto s : statements) {
for (std::size_t i = 0; i < statements.size(); ++i) {
SqlStatement *s = statements[i];
PostgresStatement *ps = dynamic_cast<PostgresStatement *>(s);
ps->rebuild();
}
Expand Down
17 changes: 7 additions & 10 deletions src/Wt/WWebWidget.C
Original file line number Diff line number Diff line change
Expand Up @@ -709,19 +709,16 @@ void WWebWidget::calcZIndex()

WWebWidget *ww = parentWebWidget();
if (ww) {
if (ww == Wt::WApplication::instance()->domRoot()) {
layoutImpl_->zIndex_ = baseZIndex();
} else {
const std::vector<WWidget *>& children = ww->children();
const std::vector<WWidget *>& children = ww->children();

int maxZ = 0;
for (unsigned i = 0; i < children.size(); ++i) {
WWebWidget *wi = children[i]->webWidget();
int maxZ = 0;
for (unsigned i = 0; i < children.size(); ++i) {
WWebWidget *wi = children[i]->webWidget();
if (wi->baseZIndex() <= baseZIndex())
maxZ = std::max(maxZ, wi->zIndex());
}

layoutImpl_->zIndex_ = maxZ + 100;
}

layoutImpl_->zIndex_ = std::max(baseZIndex(), maxZ + 100);
}
}

Expand Down

0 comments on commit bae7dc7

Please sign in to comment.