X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ftext_content.cc;h=a85b271a88d23dbfca216491e5777e701c720f03;hb=62c03e3d3493df8a31361b3281c443cac35decb0;hp=9c925cbcfb6bb0c6849fba9a947c66c70e7fa36b;hpb=5a820bb8fae34591be5ac6d19a73461b9dab532a;p=dcpomatic.git diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc index 9c925cbcf..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; @@ -664,3 +674,12 @@ TextContent::get_font(string id) const return *iter; } + +void +TextContent::clear_fonts() +{ + boost::mutex::scoped_lock lm(_mutex); + + _fonts.clear(); +} +