[gimp/gimp-2-10] gimp-updates: fix update checks on macOS
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] gimp-updates: fix update checks on macOS
- Date: Tue, 6 Sep 2022 22:35:07 +0000 (UTC)
commit 4d61f0d1298e183314eba2a678753993f3b8df1e
Author: Lukas Oberhuber <lukaso gmail com>
Date: Tue Sep 6 21:29:18 2022 +0100
gimp-updates: fix update checks on macOS
Update processing has to be done on the main thread to avoid
problems with GTK thread safety.
(cherry picked from commit 7f257a3a33ea2df0fb3e06d66b19842dc92a0636)
Conflicts fixed:
app/gimp-update.c
app/gimp-update.c | 88 +++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 62 insertions(+), 26 deletions(-)
---
diff --git a/app/gimp-update.c b/app/gimp-update.c
index 72f74e0366..79d7b38612 100644
--- a/app/gimp-update.c
+++ b/app/gimp-update.c
@@ -46,28 +46,34 @@
#include "gimp-update.h"
#include "gimp-version.h"
-static gboolean gimp_update_known (GimpCoreConfig *config,
- const gchar *last_version,
- gint64 release_timestamp,
- gint build_revision,
- const gchar *comment);
-static gboolean gimp_version_break (const gchar *v,
- gint *major,
- gint *minor,
- gint *micro);
-static void gimp_check_updates_process (const gchar *source,
- gchar *file_contents,
- gsize file_length,
- GimpCoreConfig *config);
+static gboolean gimp_update_known (GimpCoreConfig *config,
+ const gchar *last_version,
+ gint64 release_timestamp,
+ gint build_revision,
+ const gchar *comment);
+static void gimp_check_updates_process (const gchar *source,
+ gchar *file_contents,
+ gsize file_length,
+ GimpCoreConfig *config);
#ifndef PLATFORM_OSX
-static void gimp_check_updates_callback (GObject *source,
- GAsyncResult *result,
- gpointer user_data);
+static void gimp_check_updates_callback (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data);
#endif /* PLATFORM_OSX */
-static void gimp_update_about_dialog (GimpCoreConfig *config,
- const GParamSpec *pspec,
- gpointer user_data);
-static const gchar * gimp_get_version_url (void);
+static void gimp_update_about_dialog (GimpCoreConfig *config,
+ const GParamSpec *pspec,
+ gpointer user_data);
+
+static gboolean gimp_version_break (const gchar *v,
+ gint *major,
+ gint *minor,
+ gint *micro);
+
+static const gchar * gimp_get_version_url (void);
+
+#ifdef PLATFORM_OSX
+static gint gimp_check_updates_process_idle (gpointer data);
+#endif
/* Private Functions */
@@ -426,6 +432,31 @@ gimp_get_version_url ()
#endif
}
+#ifdef PLATFORM_OSX
+typedef struct _GimpCheckUpdatesData
+{
+ const gchar *gimp_versions;
+ gchar *json_result;
+ gsize json_size;
+ GimpCoreConfig *config;
+} GimpCheckUpdatesData;
+
+static int
+gimp_check_updates_process_idle (gpointer data)
+{
+ GimpCheckUpdatesData *check_updates_data = (GimpCheckUpdatesData *) data;
+
+ gimp_check_updates_process (check_updates_data->gimp_versions,
+ check_updates_data->json_result,
+ check_updates_data->json_size,
+ check_updates_data->config);
+
+ g_free (check_updates_data);
+
+ return FALSE; /* remove idle */
+}
+#endif /* PLATFORM_OSX */
+
/* Public Functions */
/*
@@ -500,8 +531,9 @@ gimp_update_check (GimpCoreConfig *config)
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration
defaultSessionConfiguration]];
/* completionHandler is called on a background thread */
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError
*error) {
- NSString *reply;
- gchar *json_result;
+ NSString *reply;
+ gchar *json_result;
+ GimpCheckUpdatesData *update_results;
if (error)
{
@@ -528,10 +560,14 @@ gimp_update_check (GimpCoreConfig *config)
reply = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
json_result = g_strdup ([reply UTF8String]); /* will be freed by gimp_check_updates_process */
- gimp_check_updates_process (gimp_versions,
- json_result,
- [reply lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
- config);
+ update_results = g_new (GimpCheckUpdatesData, 1);
+
+ update_results->gimp_versions = gimp_versions;
+ update_results->json_result = json_result;
+ update_results->json_size = [reply lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+ update_results->config = config;
+
+ g_idle_add ((GSourceFunc) gimp_check_updates_process_idle, (gpointer) update_results);
}] resume];
#else
GFile *gimp_versions;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]