From 1266a5149e056a17b4a9276ccf6ea4a79cc93610 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 9 Jun 2022 22:45:24 +0200 Subject: [PATCH] Add some missing locking. --- src/lib/text_content.cc | 14 +++++++++++++- src/lib/text_content.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc index e91b7bcc0..a85b271a8 100644 --- a/src/lib/text_content.cc +++ b/src/lib/text_content.cc @@ -445,7 +445,9 @@ TextContent::identifier () const void TextContent::add_font (shared_ptr font) { - DCPOMATIC_ASSERT(!get_font(font->id())); + boost::mutex::scoped_lock lm(_mutex); + + DCPOMATIC_ASSERT(!get_font_unlocked(font->id())); _fonts.push_back (font); connect_to_fonts (); } @@ -652,6 +654,14 @@ TextContent::take_settings_from (shared_ptr c) shared_ptr TextContent::get_font(string id) const +{ + boost::mutex::scoped_lock lm(_mutex); + return get_font_unlocked(id); +} + + +shared_ptr +TextContent::get_font_unlocked(string id) const { auto iter = std::find_if(_fonts.begin(), _fonts.end(), [&id](shared_ptr font) { return font->id() == id; @@ -668,6 +678,8 @@ TextContent::get_font(string id) const void TextContent::clear_fonts() { + boost::mutex::scoped_lock lm(_mutex); + _fonts.clear(); } diff --git a/src/lib/text_content.h b/src/lib/text_content.h index 7ddb20b08..7c060cd48 100644 --- a/src/lib/text_content.h +++ b/src/lib/text_content.h @@ -206,6 +206,7 @@ private: void font_changed (); void connect_to_fonts (); + std::shared_ptr get_font_unlocked(std::string id) const; std::list _font_connections; -- 2.30.2