From 15ab5e155863837e6d8596a9a70f4def1c377598 Mon Sep 17 00:00:00 2001 From: antao Date: Thu, 21 Feb 2019 15:46:54 +0800 Subject: [PATCH] Use nullptr to clear std::function objects --- orm_lib/src/mysql_impl/MysqlConnection.cc | 8 +++--- orm_lib/src/postgresql_impl/PgConnection.cc | 30 ++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/orm_lib/src/mysql_impl/MysqlConnection.cc b/orm_lib/src/mysql_impl/MysqlConnection.cc index 61d588e9..6681926d 100644 --- a/orm_lib/src/mysql_impl/MysqlConnection.cc +++ b/orm_lib/src/mysql_impl/MysqlConnection.cc @@ -434,10 +434,10 @@ void MysqlConnection::outputError() catch (...) { _exceptCb(std::current_exception()); - _exceptCb = decltype(_exceptCb)(); + _exceptCb = nullptr; } - _cb = decltype(_cb)(); + _cb = nullptr; _isWorking = false; if (_idleCbPtr) { @@ -457,8 +457,8 @@ void MysqlConnection::getResult(MYSQL_RES *res) if (_isWorking) { _cb(Result); - _cb = decltype(_cb)(); - _exceptCb = decltype(_exceptCb)(); + _cb = nullptr; + _exceptCb = nullptr; _isWorking = false; if (_idleCbPtr) { diff --git a/orm_lib/src/postgresql_impl/PgConnection.cc b/orm_lib/src/postgresql_impl/PgConnection.cc index 39b1e20a..bfbe5794 100644 --- a/orm_lib/src/postgresql_impl/PgConnection.cc +++ b/orm_lib/src/postgresql_impl/PgConnection.cc @@ -197,9 +197,9 @@ void PgConnection::execSqlInLoop(std::string &&sql, { auto exceptPtr = std::current_exception(); _exceptCb(exceptPtr); - _exceptCb = decltype(_exceptCb)(); + _exceptCb = nullptr; } - _cb = decltype(_cb)(); + _cb = nullptr; if (_idleCbPtr) { auto idle = std::move(_idleCbPtr); @@ -237,9 +237,9 @@ void PgConnection::execSqlInLoop(std::string &&sql, { auto exceptPtr = std::current_exception(); _exceptCb(exceptPtr); - _exceptCb = decltype(_exceptCb)(); + _exceptCb = nullptr; } - _cb = decltype(_cb)(); + _cb = nullptr; if (_idleCbPtr) { auto idle = std::move(_idleCbPtr); @@ -268,9 +268,9 @@ void PgConnection::execSqlInLoop(std::string &&sql, { auto exceptPtr = std::current_exception(); _exceptCb(exceptPtr); - _exceptCb = decltype(_exceptCb)(); + _exceptCb = nullptr; } - _cb = decltype(_cb)(); + _cb = nullptr; if (_idleCbPtr) { auto idle = std::move(_idleCbPtr); @@ -312,9 +312,9 @@ void PgConnection::execSqlInLoop(std::string &&sql, { auto exceptPtr = std::current_exception(); thisPtr->_exceptCb(exceptPtr); - thisPtr->_exceptCb = decltype(thisPtr->_exceptCb)(); + thisPtr->_exceptCb = nullptr; } - thisPtr->_cb = decltype(thisPtr->_cb)(); + thisPtr->_cb = nullptr; if (thisPtr->_idleCbPtr) { auto idle = std::move(thisPtr->_idleCbPtr); @@ -349,9 +349,9 @@ void PgConnection::handleRead() { auto exceptPtr = std::current_exception(); _exceptCb(exceptPtr); - _exceptCb = decltype(_exceptCb)(); + _exceptCb = nullptr; } - _cb = decltype(_cb)(); + _cb = nullptr; if (_idleCbPtr) { //auto idle = std::move(_idleCbPtr); @@ -388,9 +388,9 @@ void PgConnection::handleRead() catch (...) { _exceptCb(std::current_exception()); - _exceptCb = decltype(_exceptCb)(); + _exceptCb = nullptr; } - _cb = decltype(_cb)(); + _cb = nullptr; } } else @@ -405,8 +405,8 @@ void PgConnection::handleRead() { auto r = makeResult(res, _sql); _cb(r); - _cb = decltype(_cb)(); - _exceptCb = decltype(_exceptCb)(); + _cb = nullptr; + _exceptCb = nullptr; } } } @@ -416,7 +416,7 @@ void PgConnection::handleRead() if (isPreparing) { _preparingCallback(); - _preparingCallback = std::function(); + _preparingCallback = nullptr; } else {