Moved dynamic font list from static to lifetime controlled by main.
Means the list is destroyed before the OS object, allowing it the opportunity to print an error if there are still dynamic font objects hanging around.
This commit is contained in:
parent
cf7a66195f
commit
7d82bed4f4
|
@ -1029,7 +1029,7 @@ void DynamicFont::_bind_methods() {
|
||||||
|
|
||||||
Mutex *DynamicFont::dynamic_font_mutex = NULL;
|
Mutex *DynamicFont::dynamic_font_mutex = NULL;
|
||||||
|
|
||||||
SelfList<DynamicFont>::List DynamicFont::dynamic_fonts;
|
SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = NULL;
|
||||||
|
|
||||||
DynamicFont::DynamicFont() :
|
DynamicFont::DynamicFont() :
|
||||||
font_list(this) {
|
font_list(this) {
|
||||||
|
@ -1041,29 +1041,31 @@ DynamicFont::DynamicFont() :
|
||||||
spacing_char = 0;
|
spacing_char = 0;
|
||||||
spacing_space = 0;
|
spacing_space = 0;
|
||||||
outline_color = Color(1, 1, 1);
|
outline_color = Color(1, 1, 1);
|
||||||
if (dynamic_font_mutex)
|
if (dynamic_font_mutex) {
|
||||||
dynamic_font_mutex->lock();
|
dynamic_font_mutex->lock();
|
||||||
dynamic_fonts.add(&font_list);
|
dynamic_fonts->add(&font_list);
|
||||||
if (dynamic_font_mutex)
|
|
||||||
dynamic_font_mutex->unlock();
|
dynamic_font_mutex->unlock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DynamicFont::~DynamicFont() {
|
DynamicFont::~DynamicFont() {
|
||||||
|
if (dynamic_font_mutex) {
|
||||||
if (dynamic_font_mutex)
|
|
||||||
dynamic_font_mutex->lock();
|
dynamic_font_mutex->lock();
|
||||||
dynamic_fonts.remove(&font_list);
|
dynamic_fonts->remove(&font_list);
|
||||||
if (dynamic_font_mutex)
|
|
||||||
dynamic_font_mutex->unlock();
|
dynamic_font_mutex->unlock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DynamicFont::initialize_dynamic_fonts() {
|
void DynamicFont::initialize_dynamic_fonts() {
|
||||||
|
dynamic_fonts = memnew(SelfList<DynamicFont>::List());
|
||||||
dynamic_font_mutex = Mutex::create();
|
dynamic_font_mutex = Mutex::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicFont::finish_dynamic_fonts() {
|
void DynamicFont::finish_dynamic_fonts() {
|
||||||
memdelete(dynamic_font_mutex);
|
memdelete(dynamic_font_mutex);
|
||||||
dynamic_font_mutex = NULL;
|
dynamic_font_mutex = NULL;
|
||||||
|
memdelete(dynamic_fonts);
|
||||||
|
dynamic_fonts = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicFont::update_oversampling() {
|
void DynamicFont::update_oversampling() {
|
||||||
|
@ -1073,7 +1075,7 @@ void DynamicFont::update_oversampling() {
|
||||||
if (dynamic_font_mutex)
|
if (dynamic_font_mutex)
|
||||||
dynamic_font_mutex->lock();
|
dynamic_font_mutex->lock();
|
||||||
|
|
||||||
SelfList<DynamicFont> *E = dynamic_fonts.first();
|
SelfList<DynamicFont> *E = dynamic_fonts->first();
|
||||||
while (E) {
|
while (E) {
|
||||||
|
|
||||||
if (E->self()->data_at_size.is_valid()) {
|
if (E->self()->data_at_size.is_valid()) {
|
||||||
|
|
|
@ -285,7 +285,7 @@ public:
|
||||||
SelfList<DynamicFont> font_list;
|
SelfList<DynamicFont> font_list;
|
||||||
|
|
||||||
static Mutex *dynamic_font_mutex;
|
static Mutex *dynamic_font_mutex;
|
||||||
static SelfList<DynamicFont>::List dynamic_fonts;
|
static SelfList<DynamicFont>::List *dynamic_fonts;
|
||||||
|
|
||||||
static void initialize_dynamic_fonts();
|
static void initialize_dynamic_fonts();
|
||||||
static void finish_dynamic_fonts();
|
static void finish_dynamic_fonts();
|
||||||
|
|
Loading…
Reference in New Issue