app: we always need to freeze/thaw around gimp_font_factory_data_init()

so pull it to the parent class. Also remove the "no_data" parameter
from the data_init() virtual function and handle it in
gimp_font_factory_data_init() itself.
This commit is contained in:
Michael Natterer 2018-06-03 23:16:29 +02:00
parent 1d2ff6aa1b
commit d1b9f74c6f
3 changed files with 34 additions and 43 deletions

View File

@ -105,8 +105,7 @@ static gint64 gimp_data_factory_get_memsize (GimpObject *ob
gint64 *gui_size); gint64 *gui_size);
static void gimp_data_factory_real_data_init (GimpDataFactory *factory, static void gimp_data_factory_real_data_init (GimpDataFactory *factory,
GimpContext *context, GimpContext *context);
gboolean no_data);
static void gimp_data_factory_real_data_refresh (GimpDataFactory *factory, static void gimp_data_factory_real_data_refresh (GimpDataFactory *factory,
GimpContext *context); GimpContext *context);
static void gimp_data_factory_real_data_save (GimpDataFactory *factory); static void gimp_data_factory_real_data_save (GimpDataFactory *factory);
@ -338,29 +337,9 @@ gimp_data_factory_get_memsize (GimpObject *object,
static void static void
gimp_data_factory_real_data_init (GimpDataFactory *factory, gimp_data_factory_real_data_init (GimpDataFactory *factory,
GimpContext *context, GimpContext *context)
gboolean no_data)
{ {
GimpDataFactoryPrivate *priv = GET_PRIVATE (factory); gimp_data_factory_data_load (factory, context, NULL);
/* Freeze and thaw the container even if no_data,
* this creates the standard data that serves as fallback.
*/
gimp_container_freeze (priv->container);
if (! no_data)
{
if (priv->gimp->be_verbose)
{
const gchar *name = gimp_object_get_name (factory);
g_print ("Loading '%s' data\n", name ? name : "???");
}
gimp_data_factory_data_load (factory, context, NULL);
}
gimp_container_thaw (priv->container);
} }
static void static void
@ -664,7 +643,25 @@ gimp_data_factory_data_init (GimpDataFactory *factory,
g_return_if_fail (GIMP_IS_DATA_FACTORY (factory)); g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (GIMP_IS_CONTEXT (context));
GIMP_DATA_FACTORY_GET_CLASS (factory)->data_init (factory, context, no_data); /* Always freeze() and thaw() the container around initialization,
* even if no_data, the thaw() will implicitly make GimpContext
* create the standard data that serves as fallback.
*/
gimp_container_freeze (priv->container);
if (! no_data)
{
if (priv->gimp->be_verbose)
{
const gchar *name = gimp_object_get_name (factory);
g_print ("Loading '%s' data\n", name ? name : "???");
}
GIMP_DATA_FACTORY_GET_CLASS (factory)->data_init (factory, context);
}
gimp_container_thaw (priv->container);
signal_name = g_strdup_printf ("notify::%s", priv->path_property_name); signal_name = g_strdup_printf ("notify::%s", priv->path_property_name);
g_signal_connect_object (priv->gimp->config, signal_name, g_signal_connect_object (priv->gimp->config, signal_name,

View File

@ -67,8 +67,7 @@ struct _GimpDataFactoryClass
GimpObjectClass parent_class; GimpObjectClass parent_class;
void (* data_init) (GimpDataFactory *factory, void (* data_init) (GimpDataFactory *factory,
GimpContext *context, GimpContext *context);
gboolean no_data);
void (* data_refresh) (GimpDataFactory *factory, void (* data_refresh) (GimpDataFactory *factory,
GimpContext *context); GimpContext *context);
void (* data_save) (GimpDataFactory *factory); void (* data_save) (GimpDataFactory *factory);

View File

@ -66,8 +66,7 @@ struct _GimpFontFactoryPrivate
static void gimp_font_factory_data_init (GimpDataFactory *factory, static void gimp_font_factory_data_init (GimpDataFactory *factory,
GimpContext *context, GimpContext *context);
gboolean no_data);
static void gimp_font_factory_data_refresh (GimpDataFactory *factory, static void gimp_font_factory_data_refresh (GimpDataFactory *factory,
GimpContext *context); GimpContext *context);
static void gimp_font_factory_data_save (GimpDataFactory *factory); static void gimp_font_factory_data_save (GimpDataFactory *factory);
@ -127,22 +126,18 @@ gimp_font_factory_init (GimpFontFactory *factory)
static void static void
gimp_font_factory_data_init (GimpDataFactory *factory, gimp_font_factory_data_init (GimpDataFactory *factory,
GimpContext *context, GimpContext *context)
gboolean no_data)
{ {
if (! no_data) GError *error = NULL;
gimp_font_factory_load (GIMP_FONT_FACTORY (factory), &error);
if (error)
{ {
GError *error = NULL; gimp_message_literal (gimp_data_factory_get_gimp (factory), NULL,
GIMP_MESSAGE_INFO,
gimp_font_factory_load (GIMP_FONT_FACTORY (factory), &error); error->message);
g_error_free (error);
if (error)
{
gimp_message_literal (gimp_data_factory_get_gimp (factory), NULL,
GIMP_MESSAGE_INFO,
error->message);
g_error_free (error);
}
} }
} }