Commit c11faa4e authored by Davis King's avatar Davis King

Changed all the font* pointers to shared_ptr_thread_safe objects.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402531
parent c9079be5
......@@ -1092,7 +1092,7 @@ namespace dlib
class tooltip_window : public base_window
{
public:
tooltip_window (const font* f) : base_window(false,true), pad(3), mfont(f)
tooltip_window (const shared_ptr_thread_safe<font>& f) : base_window(false,true), pad(3), mfont(f)
{
}
......@@ -1100,7 +1100,7 @@ namespace dlib
rectangle rect_all;
rectangle rect_text;
const unsigned long pad;
const font* mfont;
const shared_ptr_thread_safe<font> mfont;
void set_text (
const std::string& str
......@@ -1410,7 +1410,7 @@ namespace dlib
private:
dlib::ustring text;
const font* f;
const shared_ptr_thread_safe<font> f;
member_function_pointer<>::kernel_1a action;
unichar hotkey;
point underline_p1;
......@@ -1556,7 +1556,7 @@ namespace dlib
private:
dlib::ustring text;
const font* f;
const shared_ptr_thread_safe<font> f;
member_function_pointer<>::kernel_1a action;
unichar hotkey;
point underline_p1;
......
......@@ -344,7 +344,7 @@ namespace dlib
}
virtual void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -352,9 +352,10 @@ namespace dlib
parent.invalidate_rectangle(rect);
}
const font* main_font (
const shared_ptr_thread_safe<font> main_font (
) const
{
auto_mutex M(m);
return mfont;
}
......@@ -419,7 +420,7 @@ namespace dlib
bool enabled;
const long& lastx;
const long& lasty;
const font* mfont;
shared_ptr_thread_safe<font> mfont;
void enable_events (
......
......@@ -359,7 +359,7 @@ namespace dlib
!*/
virtual void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
/*!
ensures
......@@ -368,7 +368,7 @@ namespace dlib
- parent_window() is updated to reflect the new state of #*this
!*/
const font* main_font (
const shared_ptr_thread_safe<font> main_font (
) const;
/*!
ensures
......@@ -458,7 +458,7 @@ namespace dlib
bool enabled;
// This is the font pointer returned by main_font()
const font* mfont;
shared_ptr_thread_safe<font> mfont;
// This is the x coordinate that we last saw the mouse at or -1 if the mouse
// is outside the parent window.
......
......@@ -13,7 +13,7 @@
#include "../array.h"
#include "../array2d.h"
#include "../threads.h"
#include "../smart_pointers.h"
#include "../smart_pointers_thread_safe.h"
namespace dlib
{
......@@ -494,16 +494,16 @@ namespace dlib
public:
static const font* get_font (
static const shared_ptr_thread_safe<font>& get_font (
)
{
static mutex m;
static scoped_ptr<default_font> f;
static shared_ptr_thread_safe<font> f;
auto_mutex M(m);
if (f.get() == 0)
f.reset(new default_font);
return f.get();
return f;
}
~default_font(
......
......@@ -387,13 +387,11 @@ namespace dlib
!*/
public:
static const font* get_font(
static const shared_ptr_thread_safe<font> get_font(
);
/*!
ensures
- returns an instance of this font.
(Note that you do not need to and should NOT call delete on the
returned pointer)
throws
- std::bad_alloc
This exception is thrown if there is a problem gathering the needed
......
......@@ -131,7 +131,7 @@ namespace dlib
void button::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -395,7 +395,7 @@ namespace dlib
void toggle_button::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -544,7 +544,7 @@ namespace dlib
void label::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -697,7 +697,7 @@ namespace dlib
void text_field::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -1847,7 +1847,7 @@ namespace dlib
void tabbed_display::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -1989,7 +1989,7 @@ namespace dlib
void named_rectangle::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -2167,7 +2167,7 @@ namespace dlib
void mouse_tracker::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......@@ -2375,7 +2375,7 @@ namespace dlib
template <typename S>
void list_box<S>::
set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......
......@@ -88,7 +88,7 @@ namespace dlib
) const;
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
private:
......@@ -182,7 +182,7 @@ namespace dlib
) const;
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
void show (
......@@ -367,7 +367,7 @@ namespace dlib
);
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
void set_pos (
......@@ -576,7 +576,7 @@ namespace dlib
);
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
int next_free_user_event_number (
......@@ -903,7 +903,7 @@ namespace dlib
);
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
void fit_to_contents (
......@@ -1022,7 +1022,7 @@ namespace dlib
);
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
protected:
......@@ -1081,7 +1081,7 @@ namespace dlib
);
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
protected:
......@@ -1554,7 +1554,7 @@ namespace dlib
) const;
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
);
private:
......@@ -2140,7 +2140,7 @@ namespace dlib
void set_pos(long,long){}
void set_main_font (
const font* f
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
......
......@@ -432,13 +432,15 @@ public:
{
bool use_bdf_fonts = false;
shared_ptr_thread_safe<bdf_font> f(new bdf_font);
if (use_bdf_fonts)
{
ifstream fin("/home/davis/source/10x20.bdf");
f.read_bdf_file(fin,0xFFFF);
f->read_bdf_file(fin,0xFFFF);
mt.set_main_font(&f);
mt.set_main_font(f);
}
//mt.hide();
mt.set_pos(5,200);
......@@ -465,7 +467,7 @@ public:
lb.set_pos(580,200);
lb.set_size(200,300);
if (use_bdf_fonts)
lb.set_main_font(&f);
lb.set_main_font(f);
dlib::queue<string>::kernel_2a_c qos;
string a;
......@@ -597,7 +599,7 @@ public:
if (use_bdf_fonts)
rb.set_main_font(&f);
rb.set_main_font(f);
rb.set_name("radio button");
rb.set_pos(sb_shown.get_rect().left(),sb_shown.get_rect().bottom()+2);
......@@ -641,7 +643,7 @@ public:
b.set_click_handler(*this,&win::on_click);
b.set_tooltip_text("hurray i'm a button!");
if (use_bdf_fonts)
b.set_main_font(&f);
b.set_main_font(f);
set_size(800,500);
......@@ -658,9 +660,9 @@ public:
save_file_box(*this,&win::on_open_file);
if (use_bdf_fonts)
tf.set_main_font(&f);
tf.set_main_font(f);
if (use_bdf_fonts)
tabs.set_main_font(&f);
tabs.set_main_font(f);
}
......@@ -728,7 +730,6 @@ private:
label cbl;
check_box cbox;
int count;
bdf_font f;
int flip;
widget_group group1;
widget_group group2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment