aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu/text.cpp')
-rw-r--r--src/menu/text.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/menu/text.cpp b/src/menu/text.cpp
index 88af9076..9cfc8218 100644
--- a/src/menu/text.cpp
+++ b/src/menu/text.cpp
@@ -69,6 +69,7 @@ namespace usdx
void Text::realign(void)
{
+ boost::shared_lock<boost::shared_mutex> lock(font_mutex);
Rectangle<int> bbox = makeRect(font->BBox(text.c_str()));
bbox.get_point1().set_y(font->Ascender());
bbox.get_point2().set_y(font->Descender());
@@ -79,7 +80,7 @@ namespace usdx
{
DrawableControl::draw();
- boost::mutex::scoped_lock lock(font_mutex);
+ boost::shared_lock<boost::shared_mutex> lock(font_mutex);
glTranslatef(offset.get_x(), offset.get_y(), 0.0f);
// invert y axis, text is drawn using window orientation (origin is
@@ -90,25 +91,33 @@ namespace usdx
void Text::set_font_size(unsigned int value)
{
- boost::mutex::scoped_lock lock(font_mutex);
- font->FaceSize(value);
+ {
+ boost::unique_lock<boost::shared_mutex> lock(font_mutex);
+ font->FaceSize(value);
+ }
+
realign();
}
unsigned int Text::get_font_size(void) const
{
+ boost::shared_lock<boost::shared_mutex> lock(font_mutex);
return font->FaceSize();
}
void Text::set_text(const std::string value)
{
- boost::mutex::scoped_lock lock(font_mutex);
- text = value;
+ {
+ boost::unique_lock<boost::shared_mutex> lock(font_mutex);
+ text = value;
+ }
+
realign();
}
std::string Text::get_text(void) const
{
+ boost::shared_lock<boost::shared_mutex> lock(font_mutex);
return text;
}