diff --git a/ChangeLog b/ChangeLog index acde2ed..f6f9b8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +v0.6 (11/10/2015) +** Dev ** + Use transactions for SQL updates + v0.5 (19/06/2015) ** User ** Add tag management diff --git a/src/controller/KissCount.hpp b/src/controller/KissCount.hpp index 14ee33e..7e3ebbf 100644 --- a/src/controller/KissCount.hpp +++ b/src/controller/KissCount.hpp @@ -1,5 +1,5 @@ /* - Copyright 2010-2012 Grégory Soutadé + Copyright 2010-2015 Grégory Soutadé This file is part of KissCount. @@ -30,7 +30,7 @@ #include -#define APP_VERSION "0.5" +#define APP_VERSION "0.6" #define ESCAPE_CHARS(s) s = s.replace("\"", " "); // #define ESCAPE_CHARS(s) s = s.replace("\"", "\\\""); s = s.replace("\'", "\\\'"); diff --git a/src/model/Database.cpp b/src/model/Database.cpp index a433410..af155c6 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -1,5 +1,5 @@ /* - Copyright 2010-2012 Grégory Soutadé + Copyright 2010-2015 Grégory Soutadé This file is part of KissCount. diff --git a/src/model/Database.hpp b/src/model/Database.hpp index 817e78d..be6ec13 100644 --- a/src/model/Database.hpp +++ b/src/model/Database.hpp @@ -49,6 +49,7 @@ #define EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \ do { \ + _db.transaction(); \ QSqlQuery query; \ if (!query.exec(req)) \ { \ @@ -56,22 +57,26 @@ std::cerr << __FUNCTION__ << " " << __FILE__ << " " << __LINE__ << "\n" ; \ std::cerr << req.toStdString() << "\n" ; \ std::cerr << query.lastError().text().toStdString() << "\n" ; \ + _db.rollback(); \ + code_if_fail; \ + return return_value; \ + } \ + _db.commit(); \ + } while(0); + +#define EXECUTE_SQL_QUERY_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \ + do { \ + if (!query.exec(req)) \ + { \ + QMessageBox::critical(0, _("Error"), _("Query failed !\n") + req); \ + std::cerr << __FUNCTION__ << "\n" ; \ + std::cerr << req.toStdString() << "\n" ; \ + std::cerr << query.lastError().text().toStdString() << "\n" ; \ code_if_fail; \ return return_value; \ } \ } while(0); -#define EXECUTE_SQL_QUERY_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \ - if (!query.exec(req)) \ - { \ - QMessageBox::critical(0, _("Error"), _("Query failed !\n") + req); \ - std::cerr << __FUNCTION__ << "\n" ; \ - std::cerr << req.toStdString() << "\n" ; \ - std::cerr << query.lastError().text().toStdString() << "\n" ; \ - code_if_fail; \ - return return_value; \ - } \ - #define EXECUTE_SQL_QUERY(req, return_value) EXECUTE_SQL_QUERY_WITH_CODE(req, return_value, {}, {}) #define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {}) diff --git a/src/view/wxUI.cpp b/src/view/wxUI.cpp index c31dd6d..5672a34 100644 --- a/src/view/wxUI.cpp +++ b/src/view/wxUI.cpp @@ -310,7 +310,6 @@ void wxUI::ChangeUser() } catch (UsersDialog::ExceptionNewUser e) { - } }