X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Ftext_content.cc;h=e4cbc601a0774716354538f354213fdfe354f93f;hb=e46302d86c7295bd95cd7cdfa331c8186fe793cb;hp=9c925cbcfb6bb0c6849fba9a947c66c70e7fa36b;hpb=5a820bb8fae34591be5ac6d19a73461b9dab532a;p=dcpomatic.git diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc index 9c925cbcf..e4cbc601a 100644 --- a/src/lib/text_content.cc +++ b/src/lib/text_content.cc @@ -81,9 +81,9 @@ TextContent::TextContent (Content* parent, TextType type, TextType original_type } /** @return TextContents from node or nodes under node (according to version). - * The list could be empty if no TextContents are found. + * The vector could be empty if no TextContents are found. */ -list> +vector> TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version, list& notes) { if (version < 34) { @@ -104,14 +104,15 @@ TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version, li return { make_shared(parent, node, version, notes) }; } - list> c; + vector> content; for (auto i: node->node_children("Text")) { - c.push_back (make_shared(parent, i, version, notes)); + content.push_back(make_shared(parent, i, version, notes)); } - return c; + return content; } + TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version, list& notes) : ContentPart (parent) , _use (false) @@ -445,7 +446,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 +655,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 +675,12 @@ TextContent::get_font(string id) const return *iter; } + +void +TextContent::clear_fonts() +{ + boost::mutex::scoped_lock lm(_mutex); + + _fonts.clear(); +} +