app: set font factory as GimpFont class member regardless of fonts being loaded.

Previous code would only set the class member when we were actually
loading fonts, so we ended with code paths where the member was NULL.

Fixes:

> GIMP-CRITICAL: gimp_container_get_n_children: assertion 'GIMP_IS_CONTAINER (container)' failed

It should hopefully also fix #11219 (though I couldn't reproduce this
failure).
This commit is contained in:
Jehan 2024-04-11 12:10:05 +02:00
parent 3001c2d523
commit 5dc86277e6
4 changed files with 18 additions and 14 deletions

View File

@ -54,6 +54,7 @@
#include "gimptoolpreset.h"
#include "gimptoolpreset-load.h"
#include "text/gimpfont.h"
#include "text/gimpfontfactory.h"
#include "gimp-intl.h"
@ -198,6 +199,7 @@ gimp_data_factories_init (Gimp *gimp)
"font-path");
gimp_object_set_static_name (GIMP_OBJECT (gimp->font_factory),
"font factory");
gimp_font_class_set_font_factory (GIMP_FONT_FACTORY (gimp->font_factory));
gimp->tool_preset_factory =
gimp_data_loader_factory_new (gimp,

View File

@ -47,6 +47,7 @@
#include "core/gimpcontainer.h"
#include "gimpfont.h"
#include "gimpfontfactory.h"
#include "gimp-intl.h"
@ -111,7 +112,7 @@ struct _GimpFontClass
{
GimpDataClass parent_class;
GimpContainer *fontfactory;
GimpContainer *fonts_container;
};
@ -237,7 +238,7 @@ gimp_font_deserialize_create (GType type,
gpointer data)
{
GimpFont *font;
GimpContainer *fonts_container = GIMP_FONT_CLASS (g_type_class_peek (GIMP_TYPE_FONT))->fontfactory;
GimpContainer *fonts_container = GIMP_FONT_CLASS (g_type_class_peek (GIMP_TYPE_FONT))->fonts_container;
gint most_similar_font_index = -1;
gint font_count = gimp_container_get_n_children (fonts_container);
gint largest_similarity = 0;
@ -484,10 +485,13 @@ gimp_font_deserialize_create (GType type,
}
void
gimp_font_class_set_font_factory (GimpContainer *factory)
gimp_font_class_set_font_factory (GimpFontFactory *factory)
{
GimpFontClass *klass = GIMP_FONT_CLASS (g_type_class_peek (GIMP_TYPE_FONT));
klass->fontfactory = factory;
g_return_if_fail (GIMP_IS_FONT_FACTORY (factory));
klass->fonts_container = gimp_data_factory_get_container (GIMP_DATA_FACTORY (factory));
}
void

View File

@ -39,14 +39,14 @@ typedef struct _GimpFontClass GimpFontClass;
GType gimp_font_get_type (void) G_GNUC_CONST;
GimpData * gimp_font_get_standard (void);
const gchar * gimp_font_get_lookup_name (GimpFont *font);
void gimp_font_set_lookup_name (GimpFont *font,
gchar *name);
gboolean gimp_font_match_by_lookup_name (GimpFont *font,
const gchar *name);
void gimp_font_set_font_info (GimpFont *font,
gpointer font_info[]);
void gimp_font_class_set_font_factory (GimpContainer *factory);
const gchar * gimp_font_get_lookup_name (GimpFont *font);
void gimp_font_set_lookup_name (GimpFont *font,
gchar *name);
gboolean gimp_font_match_by_lookup_name (GimpFont *font,
const gchar *name);
void gimp_font_set_font_info (GimpFont *font,
gpointer font_info[]);
void gimp_font_class_set_font_factory (GimpFontFactory *factory);
enum
{

View File

@ -1006,6 +1006,4 @@ gimp_font_factory_load_names (GimpFontFactory *factory,
gimp_font_factory_load_aliases (container, context);
FcFontSetDestroy (fontset);
gimp_font_class_set_font_factory (container);
}