From 4024598bd8ff73ce8f5626d30949aaa65559a655 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 30 Mar 2025 13:01:13 +0100 Subject: [PATCH] Execute SQL updates atomically. If the Serialize call alters any tables they would have previously been missed here. --- modules/database/db_sql.cpp | 6 ++++-- modules/database/db_sql_live.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index 18572b197..979ca1000 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -109,7 +109,10 @@ public: void OnNotify() override { - for (auto *obj : this->updated_items) + std::set items; + std::swap(this->updated_items, items); + + for (auto *obj : items) { if (this->sql) { @@ -154,7 +157,6 @@ public: } } - this->updated_items.clear(); this->imported = true; } diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index c20a11a9f..24ae9f2ab 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -89,7 +89,10 @@ public: if (!this->CheckInit()) return; - for (auto *obj : this->updated_items) + std::set items; + std::swap(this->updated_items, items); + + for (auto *obj : items) { if (obj && this->SQL) { @@ -118,8 +121,6 @@ public: } } } - - this->updated_items.clear(); } EventReturn OnLoadDatabase() override