busy_handler_ = std::move(busy_handler);
r = sqlite3_busy_handler(db_, [](void* data, int count) {
Database* pDb = static_cast<Database*>(data);
- if (pDb->busy_handler_(count))
+ if (pDb->busy_handler_ && pDb->busy_handler_(count))
return 1;
return 0;
}, this);
Database(Database&& db) noexcept {
db_ = db.db_;
+ busy_handler_ = std::move(db.busy_handler_);
db.db_ = nullptr;
+ db.busy_handler_ = nullptr;
+
+ sqlite3_busy_handler(db_, [](void* data, int count) {
+ Database* pDb = static_cast<Database*>(data);
+ if (pDb->busy_handler_ && pDb->busy_handler_(count))
+ return 1;
+ return 0;
+ }, this);
}
explicit operator bool() const {
Database& operator = (Database&& db) noexcept {
if (this != &db) {
- if (db_)
- sqlite3_close_v2(db_);
- db_ = db.db_;
- db.db_ = nullptr;
+ if (db_)
+ sqlite3_close_v2(db_);
+ db_ = db.db_;
+ busy_handler_ = std::move(db.busy_handler_);
+ db.db_ = nullptr;
+ db.busy_handler_ = nullptr;
+ sqlite3_busy_handler(db_, [](void* data, int count) {
+ Database* pDb = static_cast<Database*>(data);
+ if (pDb->busy_handler_ && pDb->busy_handler_(count))
+ return 1;
+ return 0;
+ }, this);
}
return *this;