Commit 113617f5 authored by Michael Natterer's avatar Michael Natterer 😴

app: change the GimpData loading API from filename to GFile

parent 7be12ec5
......@@ -89,22 +89,22 @@ struct _AbrSampledBrushHeader
static GList * gimp_brush_load_abr_v12 (FILE *file,
AbrHeader *abr_hdr,
const gchar *filename,
const gchar *path,
GError **error);
static GList * gimp_brush_load_abr_v6 (FILE *file,
AbrHeader *abr_hdr,
const gchar *filename,
const gchar *path,
GError **error);
static GimpBrush * gimp_brush_load_abr_brush_v12 (FILE *file,
AbrHeader *abr_hdr,
gint index,
const gchar *filename,
const gchar *path,
GError **error);
static GimpBrush * gimp_brush_load_abr_brush_v6 (FILE *file,
AbrHeader *abr_hdr,
gint32 max_offset,
gint index,
const gchar *filename,
const gchar *path,
GError **error);
static gchar abr_read_char (FILE *file);
......@@ -112,7 +112,7 @@ static gint16 abr_read_short (FILE *file);
static gint32 abr_read_long (FILE *file);
static gchar * abr_read_ucs2_text (FILE *file);
static gboolean abr_supported (AbrHeader *abr_hdr,
const gchar *filename,
const gchar *path,
GError **error);
static gboolean abr_reach_8bim_section (FILE *abr,
const gchar *name);
......@@ -125,28 +125,34 @@ static gint32 abr_rle_decode (FILE *file,
GList *
gimp_brush_load (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error)
{
GimpBrush *brush;
gchar *path;
gint fd;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
path = g_file_get_path (file);
g_return_val_if_fail (g_path_is_absolute (path), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
fd = g_open (path, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
gimp_filename_to_utf8 (path), g_strerror (errno));
g_free (path);
return NULL;
}
brush = gimp_brush_load_brush (context, fd, filename, error);
brush = gimp_brush_load_brush (context, fd, path, error);
close (fd);
g_free (path);
if (! brush)
return NULL;
......@@ -157,7 +163,7 @@ gimp_brush_load (GimpContext *context,
GimpBrush *
gimp_brush_load_brush (GimpContext *context,
gint fd,
const gchar *filename,
const gchar *path,
GError **error)
{
GimpBrush *brush;
......@@ -169,7 +175,7 @@ gimp_brush_load_brush (GimpContext *context,
gssize i, size;
gboolean success = TRUE;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (fd != -1, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
......@@ -181,7 +187,7 @@ gimp_brush_load_brush (GimpContext *context,
"Could not read %d bytes from '%s': %s",
(gint) sizeof (header)),
(gint) sizeof (header),
gimp_filename_to_utf8 (filename), g_strerror (errno));
gimp_filename_to_utf8 (path), g_strerror (errno));
return NULL;
}
......@@ -201,7 +207,7 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Width = 0."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
return NULL;
}
......@@ -210,7 +216,7 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Height = 0."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
return NULL;
}
......@@ -219,7 +225,7 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Bytes = 0."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
return NULL;
}
......@@ -243,7 +249,7 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Unknown depth %d."),
gimp_filename_to_utf8 (filename), header.bytes);
gimp_filename_to_utf8 (path), header.bytes);
return NULL;
}
/* fallthrough */
......@@ -256,7 +262,7 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Unknown version %d."),
gimp_filename_to_utf8 (filename), header.version);
gimp_filename_to_utf8 (path), header.version);
return NULL;
}
......@@ -272,14 +278,14 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"File appears truncated."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
g_free (name);
return NULL;
}
utf8 = gimp_any_to_utf8 (name, -1,
_("Invalid UTF-8 string in brush file '%s'."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
g_free (name);
name = utf8;
}
......@@ -357,7 +363,7 @@ gimp_brush_load_brush (GimpContext *context,
"GIMP brushes must be GRAY or RGBA.\n"
"This might be an obsolete GIMP brush file, try "
"loading it as image and save it again."),
gimp_filename_to_utf8 (filename), header.bytes);
gimp_filename_to_utf8 (path), header.bytes);
return NULL;
break;
......@@ -400,7 +406,7 @@ gimp_brush_load_brush (GimpContext *context,
_("Fatal parse error in brush file '%s': "
"Unsupported brush depth %d\n"
"GIMP brushes must be GRAY or RGBA."),
gimp_filename_to_utf8 (filename), header.bytes);
gimp_filename_to_utf8 (path), header.bytes);
return NULL;
}
......@@ -410,7 +416,7 @@ gimp_brush_load_brush (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"File appears truncated."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
return NULL;
}
......@@ -425,53 +431,59 @@ gimp_brush_load_brush (GimpContext *context,
GList *
gimp_brush_load_abr (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error)
{
FILE *file;
gchar *path;
FILE *f;
AbrHeader abr_hdr;
GList *brush_list = NULL;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
file = g_fopen (filename, "rb");
path = g_file_get_path (file);
if (! file)
g_return_val_if_fail (g_path_is_absolute (path), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
f = g_fopen (path, "rb");
if (! f)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
gimp_filename_to_utf8 (path), g_strerror (errno));
g_free (path);
return NULL;
}
abr_hdr.version = abr_read_short (file);
abr_hdr.count = abr_read_short (file); /* sub-version for ABR v6 */
abr_hdr.version = abr_read_short (f);
abr_hdr.count = abr_read_short (f); /* sub-version for ABR v6 */
if (abr_supported (&abr_hdr, filename, error))
if (abr_supported (&abr_hdr, path, error))
{
switch (abr_hdr.version)
{
case 1:
case 2:
brush_list = gimp_brush_load_abr_v12 (file, &abr_hdr,
filename, error);
brush_list = gimp_brush_load_abr_v12 (f, &abr_hdr,
path, error);
break;
case 6:
brush_list = gimp_brush_load_abr_v6 (file, &abr_hdr,
filename, error);
brush_list = gimp_brush_load_abr_v6 (f, &abr_hdr,
path, error);
}
}
fclose (file);
fclose (f);
if (! brush_list && (error && ! *error))
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"unable to decode abr format version %d."),
gimp_filename_to_utf8 (filename), abr_hdr.version);
gimp_filename_to_utf8 (path), abr_hdr.version);
g_free (path);
return g_list_reverse (brush_list);
}
......@@ -482,7 +494,7 @@ gimp_brush_load_abr (GimpContext *context,
static GList *
gimp_brush_load_abr_v12 (FILE *file,
AbrHeader *abr_hdr,
const gchar *filename,
const gchar *path,
GError **error)
{
GList *brush_list = NULL;
......@@ -494,7 +506,7 @@ gimp_brush_load_abr_v12 (FILE *file,
GError *my_error = NULL;
brush = gimp_brush_load_abr_brush_v12 (file, abr_hdr, i,
filename, &my_error);
path, &my_error);
/* a NULL brush without an error means an unsupported brush
* type was encountered, silently skip it and try the next one
......@@ -517,7 +529,7 @@ gimp_brush_load_abr_v12 (FILE *file,
static GList *
gimp_brush_load_abr_v6 (FILE *file,
AbrHeader *abr_hdr,
const gchar *filename,
const gchar *path,
GError **error)
{
GList *brush_list = NULL;
......@@ -537,7 +549,7 @@ gimp_brush_load_abr_v6 (FILE *file,
GError *my_error = NULL;
brush = gimp_brush_load_abr_brush_v6 (file, abr_hdr, sample_section_end,
i, filename, &my_error);
i, path, &my_error);
/* a NULL brush without an error means an unsupported brush
* type was encountered, silently skip it and try the next one
......@@ -563,13 +575,13 @@ static GimpBrush *
gimp_brush_load_abr_brush_v12 (FILE *file,
AbrHeader *abr_hdr,
gint index,
const gchar *filename,
const gchar *path,
GError **error)
{
GimpBrush *brush = NULL;
AbrBrushHeader abr_brush_hdr;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
abr_brush_hdr.type = abr_read_short (file);
......@@ -638,11 +650,11 @@ gimp_brush_load_abr_brush_v12 (FILE *file,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Wide brushes are not supported."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
return NULL;
}
tmp = g_filename_display_basename (filename);
tmp = g_filename_display_basename (path);
if (! sample_name)
{
/* build name from filename and index */
......@@ -703,7 +715,7 @@ gimp_brush_load_abr_brush_v6 (FILE *file,
AbrHeader *abr_hdr,
gint32 max_offset,
gint index,
const gchar *filename,
const gchar *path,
GError **error)
{
GimpBrush *brush = NULL;
......@@ -745,7 +757,7 @@ gimp_brush_load_abr_brush_v6 (FILE *file,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"File appears truncated."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
return NULL;
}
......@@ -760,7 +772,7 @@ gimp_brush_load_abr_brush_v6 (FILE *file,
height = bottom - top;
size = width * (depth >> 3) * height;
tmp = g_filename_display_basename (filename);
tmp = g_filename_display_basename (path);
name = g_strdup_printf ("%s-%03d", tmp, index);
g_free (tmp);
......@@ -854,7 +866,7 @@ abr_read_ucs2_text (FILE *file)
static gboolean
abr_supported (AbrHeader *abr_hdr,
const gchar *filename,
const gchar *path,
GError **error)
{
switch (abr_hdr->version)
......@@ -873,7 +885,7 @@ abr_supported (AbrHeader *abr_hdr,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"unable to decode abr format version %d."),
gimp_filename_to_utf8 (filename),
gimp_filename_to_utf8 (path),
/* horrid subversion display, but better than
* having yet another translatable string for
......
......@@ -26,15 +26,15 @@
GList * gimp_brush_load (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error);
GimpBrush * gimp_brush_load_brush (GimpContext *context,
gint fd,
const gchar *filename,
const gchar *path,
GError **error);
GList * gimp_brush_load_abr (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error);
......
......@@ -43,11 +43,12 @@
GList *
gimp_brush_generated_load (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error)
{
GimpBrush *brush;
FILE *file;
gchar *path;
FILE *f;
gchar string[256];
gint linenum;
gchar *name = NULL;
......@@ -60,24 +61,27 @@ gimp_brush_generated_load (GimpContext *context,
gdouble aspect_ratio;
gdouble angle;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
path = g_file_get_path (file);
file = g_fopen (filename, "rb");
g_return_val_if_fail (g_path_is_absolute (path), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (! file)
f = g_fopen (path, "rb");
if (! f)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
gimp_filename_to_utf8 (path), g_strerror (errno));
g_free (path);
return NULL;
}
/* make sure the file we are reading is the right type */
errno = 0;
linenum = 1;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
if (! g_str_has_prefix (string, "GIMP-VBR"))
......@@ -85,14 +89,14 @@ gimp_brush_generated_load (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Not a GIMP brush file."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
goto failed;
}
/* make sure we are reading a compatible version */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
if (! g_str_has_prefix (string, "1.0"))
......@@ -102,7 +106,7 @@ gimp_brush_generated_load (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Unknown GIMP brush version in line %d."),
gimp_filename_to_utf8 (filename), linenum);
gimp_filename_to_utf8 (path), linenum);
goto failed;
}
else
......@@ -114,7 +118,7 @@ gimp_brush_generated_load (GimpContext *context,
/* read name */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
g_strstrip (string);
......@@ -125,7 +129,7 @@ gimp_brush_generated_load (GimpContext *context,
name = gimp_any_to_utf8 (string, -1,
_("Invalid UTF-8 string in brush file '%s'."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
if (have_shape)
{
......@@ -137,7 +141,7 @@ gimp_brush_generated_load (GimpContext *context,
/* read shape */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
g_strstrip (string);
......@@ -148,7 +152,7 @@ gimp_brush_generated_load (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"Unknown GIMP brush shape in line %d."),
gimp_filename_to_utf8 (filename), linenum);
gimp_filename_to_utf8 (path), linenum);
goto failed;
}
......@@ -158,14 +162,14 @@ gimp_brush_generated_load (GimpContext *context,
/* read brush spacing */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
spacing = g_ascii_strtod (string, NULL);
/* read brush radius */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
radius = g_ascii_strtod (string, NULL);
......@@ -174,7 +178,7 @@ gimp_brush_generated_load (GimpContext *context,
/* read number of spikes */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
spikes = CLAMP (atoi (string), 2, 20);
}
......@@ -182,25 +186,25 @@ gimp_brush_generated_load (GimpContext *context,
/* read brush hardness */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
hardness = g_ascii_strtod (string, NULL);
/* read brush aspect_ratio */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
aspect_ratio = g_ascii_strtod (string, NULL);
/* read brush angle */
errno = 0;
linenum++;
if (! fgets (string, sizeof (string), file))
if (! fgets (string, sizeof (string), f))
goto failed;
angle = g_ascii_strtod (string, NULL);
fclose (file);
fclose (f);
brush = GIMP_BRUSH (gimp_brush_generated_new (name, shape, radius, spikes,
hardness, aspect_ratio, angle));
......@@ -208,11 +212,13 @@ gimp_brush_generated_load (GimpContext *context,
brush->spacing = spacing;
g_free (path);
return g_list_prepend (NULL, brush);
failed:
fclose (file);
fclose (f);
if (name)
g_free (name);
......@@ -228,10 +234,12 @@ gimp_brush_generated_load (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Error while reading brush file '%s': %s"),
gimp_filename_to_utf8 (filename), msg);
gimp_filename_to_utf8 (path), msg);
g_free (msg);
}
g_free (path);
return NULL;
}
......@@ -25,7 +25,7 @@
GList * gimp_brush_generated_load (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error);
......
......@@ -55,7 +55,7 @@
GList *
gimp_brush_pipe_load (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error)
{
GimpBrushPipe *pipe = NULL;
......@@ -66,19 +66,23 @@ gimp_brush_pipe_load (GimpContext *context,
gchar *paramstring;
GString *buffer;
gchar c;
gchar *path;
gint fd;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
path = g_file_get_path (file);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
g_return_val_if_fail (g_path_is_absolute (path), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = g_open (path, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
gimp_filename_to_utf8 (path), g_strerror (errno));
g_free (path);
return NULL;
}
......@@ -94,7 +98,7 @@ gimp_brush_pipe_load (GimpContext *context,
gchar *utf8 =
gimp_any_to_utf8 (buffer->str, buffer->len,
_("Invalid UTF-8 string in brush file '%s'."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
pipe = g_object_new (GIMP_TYPE_BRUSH_PIPE,
"name", utf8,
......@@ -111,8 +115,9 @@ gimp_brush_pipe_load (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"File is corrupt."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
close (fd);
g_free (path);
return NULL;
}
......@@ -131,8 +136,9 @@ gimp_brush_pipe_load (GimpContext *context,
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ,
_("Fatal parse error in brush file '%s': "
"File is corrupt."),
gimp_filename_to_utf8 (filename));
gimp_filename_to_utf8 (path));
close (fd);
g_free (path);
g_object_unref (pipe);
g_string_free (buffer, TRUE);
return NULL;
......@@ -212,7 +218,7 @@ gimp_brush_pipe_load (GimpContext *context,
GError *my_error = NULL;
pipe->brushes[pipe->n_brushes] = gimp_brush_load_brush (context,
fd, filename,
fd, path,
&my_error);
if (pipe->brushes[pipe->n_brushes])
......@@ -224,6 +230,7 @@ gimp_brush_pipe_load (GimpContext *context,
{
g_propagate_error (error, my_error);
close (fd);
g_free (path);
g_object_unref (pipe);
return NULL;
}
......@@ -243,5 +250,7 @@ gimp_brush_pipe_load (GimpContext *context,
GIMP_BRUSH (pipe)->mask = pipe->current->mask;
GIMP_BRUSH (pipe)->pixmap = pipe->current->pixmap;
g_free (path);
return g_list_prepend (NULL, pipe);
}
......@@ -24,7 +24,7 @@
GList * gimp_brush_pipe_load (GimpContext *context,
const gchar *filename,
GFile *file,
GError **error);
......
......@@ -844,6 +844,7 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
GimpDataFactory *factory = context->factory;
GHashTable *cache = context->cache;
const GimpDataFactoryLoaderEntry *loader = NULL;
GFile *file = NULL;
GError *error = NULL;
GList *data_list;
gint i;
......@@ -865,13 +866,11 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
return;
insert:
file = g_file_new_for_path (file_data->filename);
if (cache)
{
GFile *file = g_file_new_for_path (file_data->filename);
GList *cached_data;
cached_data = g_hash_table_lookup (cache, file);
g_object_unref (file);
GList *cached_data = g_hash_table_lookup (cache, file);
if (cached_data &&
gimp_data_get_mtime (cached_data->data) != 0 &&
......@@ -882,11 +881,13 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
for (list = cached_data; list; list = g_list_next (list))
gimp_container_add (factory->priv->container, list->data);
g_object_unref (file);
return;
}
}
data_list = loader->load_func (context->context, file_data->filename, &error);
data_list = loader->load_func (context->context, file, &error);
if (G_LIKELY (data_list))
{
......@@ -916,13 +917,9 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
for (list = data_list; list; list = g_list_next (list))
{
GimpData *data = list->data;
GFile *file = g_file_new_for_path (file_data->filename);
gimp_data_set_file (data, file, writable, deletable);
gimp_data_set_mtime (data, file_data->mtime);