From ba5109189be54d4d3ec9f10749ce416e10ad982a Mon Sep 17 00:00:00 2001 From: aleos Date: Thu, 14 May 2020 11:41:37 -0400 Subject: [PATCH] Adjusts processing of updates * Temporarily store updates into a map STL so that they are applied sequentially based on their order defined in the database. --- src/common/sql.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/sql.cpp b/src/common/sql.cpp index 4792dedfa6..08d6032ecf 100644 --- a/src/common/sql.cpp +++ b/src/common/sql.cpp @@ -3,6 +3,7 @@ #include "sql.hpp" +#include #ifdef WIN32 #include "winapi.hpp" #endif @@ -1062,8 +1063,9 @@ void Sql_UpgradesChecker(Sql *sql_handle, e_sql_database schema) { sql_update_db.load(); std::vector new_updates, skipped_updates; + std::map> ordered_sql_update_db(sql_update_db.begin(), sql_update_db.end()); // Create an ordered list (by ID) to make sure updates are applied sequentially - for (const auto &updateIt : sql_update_db) { + for (const auto &updateIt : ordered_sql_update_db) { std::shared_ptr update = updateIt.second; if (!update->patchdate.empty()) // Already applied @@ -1162,6 +1164,7 @@ void Sql_UpgradesChecker(Sql *sql_handle, e_sql_database schema) { save.close(); } + ordered_sql_update_db.clear(); new_updates.clear(); skipped_updates.clear(); }