Explorar o código

I have no idea why this commit fixes #15392

Juan Linietsky %!s(int64=7) %!d(string=hai) anos
pai
achega
8daf5491ab
Modificáronse 2 ficheiros con 12 adicións e 15 borrados
  1. 3 8
      scene/resources/dynamic_font.cpp
  2. 9 7
      scene/resources/dynamic_font.h

+ 3 - 8
scene/resources/dynamic_font.cpp

@@ -35,13 +35,7 @@
 
 bool DynamicFontData::CacheID::operator<(CacheID right) const {
 
-	if (size < right.size)
-		return true;
-	if (mipmaps != right.mipmaps)
-		return right.mipmaps;
-	if (filter != right.filter)
-		return right.filter;
-	return false;
+	return key < right.key;
 }
 
 Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cache_id) {
@@ -654,6 +648,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {
 		FT_Done_FreeType(library);
 	}
 	font->size_cache.erase(id);
+	font.unref();
 }
 
 /////////////////////////
@@ -983,7 +978,7 @@ void DynamicFont::update_oversampling() {
 	while (E) {
 
 		if (E->self()->data_at_size.is_valid() && E->self()->data_at_size->update_oversampling()) {
-			changed.push_back(E->self());
+			changed.push_back(Ref<DynamicFont>(E->self()));
 		}
 		E = E->next();
 	}

+ 9 - 7
scene/resources/dynamic_font.h

@@ -50,15 +50,17 @@ class DynamicFontData : public Resource {
 public:
 	struct CacheID {
 
-		int size;
-		bool mipmaps;
-		bool filter;
-
+		union {
+			struct {
+				uint32_t size : 16;
+				bool mipmaps : 1;
+				bool filter : 1;
+			};
+			uint32_t key;
+		};
 		bool operator<(CacheID right) const;
 		CacheID() {
-			size = 16;
-			mipmaps = false;
-			filter = false;
+			key = 0;
 		}
 	};