diff options
author | Sadie Powell <sadie@witchery.services> | 2025-03-30 13:01:13 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-03-30 13:01:13 +0100 |
commit | 4024598bd8ff73ce8f5626d30949aaa65559a655 (patch) | |
tree | 6fecabd805233fa2807c4f3e2739c12319f89705 /modules | |
parent | a154532e982a1f159a7c94a1525944c7d473a687 (diff) |
Execute SQL updates atomically.
If the Serialize call alters any tables they would have previously
been missed here.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/database/db_sql.cpp | 6 | ||||
-rw-r--r-- | 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<Serializable *> 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<Serializable *> 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 |