mirror of https://github.com/GNOME/gimp.git
Issue #4904: GIMP startup SLOW due to failed access to…
… oscp-router0[12].gnome.org. The file was opened asynchronously through g_file_read_async() but the actually reading from a GFileInputStream was actually done in the callback, in the main thread. So it may be possible that file is accessible but connection is very slow or non-reliable and actual reading would block the main process. I am assuming this is what may have happened for this reporter. Instead let's use g_file_load_contents_async() which does the file opening, reading and closing all in the asynchronous task, hence would not slow down anything even if the remote resource is unavailable or connection is very slow.
This commit is contained in:
parent
6bae5d8cf7
commit
cc16ec5f9f
|
@ -82,12 +82,14 @@ gimp_check_updates_callback (GObject *source,
|
|||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFileInputStream *stream;
|
||||
GimpCoreConfig *config = user_data;
|
||||
char *file_contents = NULL;
|
||||
gsize file_length = 0;
|
||||
GError *error = NULL;
|
||||
|
||||
stream = g_file_read_finish (G_FILE (source), result, &error);
|
||||
if (stream)
|
||||
if (g_file_load_contents_finish (G_FILE (source), result,
|
||||
&file_contents, &file_length,
|
||||
NULL, &error))
|
||||
{
|
||||
const gchar *platform;
|
||||
const gchar *last_version = NULL;
|
||||
|
@ -113,11 +115,11 @@ gimp_check_updates_callback (GObject *source,
|
|||
platform = "source";
|
||||
|
||||
parser = json_parser_new ();
|
||||
if (! json_parser_load_from_stream (parser, G_INPUT_STREAM (stream), NULL, &error))
|
||||
if (! json_parser_load_from_data (parser, file_contents, file_length, &error))
|
||||
{
|
||||
g_printerr("%s: parsing of %s failed: %s\n", G_STRFUNC,
|
||||
g_file_get_uri (G_FILE (source)), error->message);
|
||||
g_clear_object (&stream);
|
||||
g_free (file_contents);
|
||||
g_clear_object (&parser);
|
||||
g_clear_error (&error);
|
||||
|
||||
|
@ -139,7 +141,7 @@ gimp_check_updates_callback (GObject *source,
|
|||
#ifdef GIMP_UNSTABLE
|
||||
g_printerr("Path compilation failed: %s\n", error->message);
|
||||
#endif
|
||||
g_clear_object (&stream);
|
||||
g_free (file_contents);
|
||||
g_clear_object (&parser);
|
||||
g_clear_error (&error);
|
||||
|
||||
|
@ -232,7 +234,13 @@ gimp_check_updates_callback (GObject *source,
|
|||
|
||||
g_object_unref (path);
|
||||
g_object_unref (parser);
|
||||
g_object_unref (stream);
|
||||
g_free (file_contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_printerr("%s: loading of %s failed: %s\n", G_STRFUNC,
|
||||
g_file_get_uri (G_FILE (source)), error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +324,7 @@ gimp_update_check (GimpCoreConfig *config)
|
|||
#else
|
||||
gimp_versions = g_file_new_for_uri ("https://gimp.org/gimp_versions.json");
|
||||
#endif
|
||||
g_file_read_async (gimp_versions, 0, NULL, gimp_check_updates_callback, config);
|
||||
g_file_load_contents_async (gimp_versions, NULL, gimp_check_updates_callback, config);
|
||||
g_object_unref (gimp_versions);
|
||||
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in New Issue