mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
plug-ins: revert the multi-threading code.
The whole multi-threading changes in the help plug-in seem to badly break on macOS. See discussion in reopened #12898. We decided to get rid of it for now and see later if we need to reimplement this (after understanding what is going on). Revert "plug-ins: fix #13049 Calling help on unknown help-id causes..." This reverts commit7d153bcc6d
. Revert "plug-ins/help: fix thread unnecessarily waiting when locale_parse failed" This reverts commitfd0ccfa16c
. Revert "plug-ins/help: fix crash when locale is NULL" This reverts commit4075add5b4
. Revert "plug-ins: fix failing to access help from within GIMP" This reverts commit38f0527ebc
. Revert "plug-ins: add some better error handling when the docs XML request/parsing fails." This reverts commit543bb374a8
. Revert "plug-ins: try to load the gimp-help.xml file in a thread." This reverts commitf2d47e910b
.
This commit is contained in:
parent
34e35f3fd5
commit
8c077d50d1
3 changed files with 25 additions and 101 deletions
|
@ -42,22 +42,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
gboolean *success;
|
|
||||||
gboolean *done;
|
|
||||||
|
|
||||||
GimpHelpLocale *locale;
|
|
||||||
const gchar *uri;
|
|
||||||
const gchar *domain;
|
|
||||||
GimpHelpProgress *progress;
|
|
||||||
GCancellable *cancellable;
|
|
||||||
GError **error;
|
|
||||||
} HelpThreadData;
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static gboolean parse_thread_func (HelpThreadData *data);
|
|
||||||
static gboolean domain_locale_parse (GimpHelpDomain *domain,
|
static gboolean domain_locale_parse (GimpHelpDomain *domain,
|
||||||
GimpHelpLocale *locale,
|
GimpHelpLocale *locale,
|
||||||
GimpHelpProgress *progress,
|
GimpHelpProgress *progress,
|
||||||
|
@ -118,12 +104,10 @@ gimp_help_domain_lookup_locale (GimpHelpDomain *domain,
|
||||||
return locale;
|
return locale;
|
||||||
|
|
||||||
locale = gimp_help_locale_new (locale_id);
|
locale = gimp_help_locale_new (locale_id);
|
||||||
|
|
||||||
if (! domain_locale_parse (domain, locale, progress, NULL))
|
|
||||||
g_clear_pointer (&locale, gimp_help_locale_free);
|
|
||||||
else
|
|
||||||
g_hash_table_insert (domain->help_locales, g_strdup (locale_id), locale);
|
g_hash_table_insert (domain->help_locales, g_strdup (locale_id), locale);
|
||||||
|
|
||||||
|
domain_locale_parse (domain, locale, progress, NULL);
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,24 +130,25 @@ gimp_help_domain_map (GimpHelpDomain *domain,
|
||||||
if (fatal_error)
|
if (fatal_error)
|
||||||
*fatal_error = FALSE;
|
*fatal_error = FALSE;
|
||||||
|
|
||||||
/* Look for a reference matching the help_id */
|
/* first pass: look for a reference matching the help_id */
|
||||||
for (list = help_locales; list && !ref; list = list->next)
|
for (list = help_locales; list && !ref; list = list->next)
|
||||||
{
|
{
|
||||||
locale = gimp_help_domain_lookup_locale (domain,
|
locale = gimp_help_domain_lookup_locale (domain,
|
||||||
(const gchar *) list->data,
|
(const gchar *) list->data,
|
||||||
progress);
|
progress);
|
||||||
if (locale)
|
|
||||||
{
|
|
||||||
ref = gimp_help_locale_map (locale, help_id);
|
ref = gimp_help_locale_map (locale, help_id);
|
||||||
/* It doesn't make sense to keep looking since all available locales
|
|
||||||
* have the same pages available. If the first locale present
|
|
||||||
* doesn't have it, the others won't have it either. */
|
|
||||||
if (! ref)
|
|
||||||
ref = locale->help_missing;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret_locale && locale)
|
/* second pass: look for a fallback */
|
||||||
|
for (list = help_locales; list && !ref; list = list->next)
|
||||||
|
{
|
||||||
|
locale = gimp_help_domain_lookup_locale (domain,
|
||||||
|
(const gchar *) list->data,
|
||||||
|
progress);
|
||||||
|
ref = locale->help_missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret_locale)
|
||||||
*ret_locale = locale;
|
*ret_locale = locale;
|
||||||
|
|
||||||
if (ref)
|
if (ref)
|
||||||
|
@ -185,7 +170,7 @@ gimp_help_domain_map (GimpHelpDomain *domain,
|
||||||
locale = gimp_help_domain_lookup_locale (domain,
|
locale = gimp_help_domain_lookup_locale (domain,
|
||||||
GIMP_HELP_DEFAULT_LOCALE, NULL);
|
GIMP_HELP_DEFAULT_LOCALE, NULL);
|
||||||
|
|
||||||
if (locale && ! domain_locale_parse (domain, locale, NULL, &error))
|
if (! domain_locale_parse (domain, locale, NULL, &error))
|
||||||
{
|
{
|
||||||
switch (error->code)
|
switch (error->code)
|
||||||
{
|
{
|
||||||
|
@ -243,34 +228,14 @@ gimp_help_domain_map (GimpHelpDomain *domain,
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
G_LOCK_DEFINE (done);
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
parse_thread_func (HelpThreadData *data)
|
|
||||||
{
|
|
||||||
|
|
||||||
*data->success = gimp_help_locale_parse (data->locale, data->uri, data->domain,
|
|
||||||
data->progress, data->cancellable, data->error);
|
|
||||||
G_LOCK (done);
|
|
||||||
*data->done = TRUE;
|
|
||||||
G_UNLOCK (done);
|
|
||||||
|
|
||||||
return *data->success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
domain_locale_parse (GimpHelpDomain *domain,
|
domain_locale_parse (GimpHelpDomain *domain,
|
||||||
GimpHelpLocale *locale,
|
GimpHelpLocale *locale,
|
||||||
GimpHelpProgress *progress,
|
GimpHelpProgress *progress,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GCancellable *cancellable;
|
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
GThread *thread;
|
gboolean success;
|
||||||
GTimer *timer;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
gboolean done = FALSE;
|
|
||||||
HelpThreadData data;
|
|
||||||
|
|
||||||
g_return_val_if_fail (domain != NULL, FALSE);
|
g_return_val_if_fail (domain != NULL, FALSE);
|
||||||
g_return_val_if_fail (locale != NULL, FALSE);
|
g_return_val_if_fail (locale != NULL, FALSE);
|
||||||
|
@ -279,41 +244,10 @@ domain_locale_parse (GimpHelpDomain *domain,
|
||||||
uri = g_strdup_printf ("%s/%s/gimp-help.xml",
|
uri = g_strdup_printf ("%s/%s/gimp-help.xml",
|
||||||
domain->help_uri, locale->locale_id);
|
domain->help_uri, locale->locale_id);
|
||||||
|
|
||||||
timer = g_timer_new ();
|
success = gimp_help_locale_parse (locale, uri, domain->help_domain,
|
||||||
cancellable = g_cancellable_new ();
|
progress, error);
|
||||||
data.done = &done;
|
|
||||||
data.success = &success;
|
|
||||||
data.locale = locale;
|
|
||||||
data.uri = uri;
|
|
||||||
data.domain = domain->help_domain;
|
|
||||||
data.progress = progress;
|
|
||||||
data.cancellable = cancellable;
|
|
||||||
data.error = error;
|
|
||||||
thread = g_thread_new (NULL, (GThreadFunc) parse_thread_func, &data);
|
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
gboolean exit;
|
|
||||||
|
|
||||||
G_LOCK (done);
|
|
||||||
exit = *data.done;
|
|
||||||
G_UNLOCK (done);
|
|
||||||
|
|
||||||
if (! exit && g_timer_elapsed (timer, NULL) > 10.0)
|
|
||||||
{
|
|
||||||
g_cancellable_cancel (cancellable);
|
|
||||||
exit = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exit)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_thread_join (thread);
|
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
g_timer_destroy (timer);
|
|
||||||
g_object_unref (cancellable);
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,11 +169,11 @@ gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
const gchar *uri,
|
const gchar *uri,
|
||||||
const gchar *help_domain,
|
const gchar *help_domain,
|
||||||
GimpHelpProgress *progress,
|
GimpHelpProgress *progress,
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GMarkupParseContext *context;
|
GMarkupParseContext *context;
|
||||||
GFile *file = NULL;
|
GFile *file = NULL;
|
||||||
|
GCancellable *cancellable = NULL;
|
||||||
LocaleParser parser = { NULL, };
|
LocaleParser parser = { NULL, };
|
||||||
#ifdef PLATFORM_OSX
|
#ifdef PLATFORM_OSX
|
||||||
NSURL *fileURL;
|
NSURL *fileURL;
|
||||||
|
@ -213,15 +213,12 @@ gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
{
|
{
|
||||||
gchar *name = g_file_get_parse_name (file);
|
gchar *name = g_file_get_parse_name (file);
|
||||||
|
|
||||||
|
cancellable = g_cancellable_new ();
|
||||||
_gimp_help_progress_start (progress, cancellable,
|
_gimp_help_progress_start (progress, cancellable,
|
||||||
_("Loading index from '%s'"), name);
|
_("Loading index from '%s'"), name);
|
||||||
|
|
||||||
|
g_clear_object (&cancellable);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
if (g_cancellable_is_cancelled (cancellable))
|
|
||||||
{
|
|
||||||
_gimp_help_progress_finish (progress);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLATFORM_OSX
|
#ifdef PLATFORM_OSX
|
||||||
|
@ -241,8 +238,6 @@ gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
locale_set_error (error,
|
locale_set_error (error,
|
||||||
_("Could not load data from '%s': %s"), file);
|
_("Could not load data from '%s': %s"), file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
if (progress)
|
|
||||||
_gimp_help_progress_finish (progress);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,13 +249,12 @@ gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
GFileInfo *info = g_file_query_info (file,
|
GFileInfo *info = g_file_query_info (file,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_SIZE, 0,
|
G_FILE_ATTRIBUTE_STANDARD_SIZE, 0,
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
if (! info || g_cancellable_is_cancelled (cancellable))
|
if (! info)
|
||||||
{
|
{
|
||||||
locale_set_error (error,
|
locale_set_error (error,
|
||||||
_("Could not open '%s' for reading: %s"), file);
|
_("Could not open '%s' for reading: %s"), file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
_gimp_help_progress_finish (progress);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,15 +265,12 @@ gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
|
|
||||||
stream = g_file_read (file, cancellable, error);
|
stream = g_file_read (file, cancellable, error);
|
||||||
|
|
||||||
if (! stream || g_cancellable_is_cancelled (cancellable))
|
if (! stream)
|
||||||
{
|
{
|
||||||
locale_set_error (error,
|
locale_set_error (error,
|
||||||
_("Could not open '%s' for reading: %s"), file);
|
_("Could not open '%s' for reading: %s"), file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
if (progress)
|
|
||||||
_gimp_help_progress_finish (progress);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif /* ! PLATFORM_OSX */
|
#endif /* ! PLATFORM_OSX */
|
||||||
|
@ -316,7 +307,7 @@ gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
g_string_free (parser.value, TRUE);
|
g_string_free (parser.value, TRUE);
|
||||||
g_free (parser.id_attr_name);
|
g_free (parser.id_attr_name);
|
||||||
|
|
||||||
if (! success || g_cancellable_is_cancelled (cancellable))
|
if (! success)
|
||||||
locale_set_error (error, _("Parse error in '%s':\n%s"), file);
|
locale_set_error (error, _("Parse error in '%s':\n%s"), file);
|
||||||
|
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
|
@ -45,7 +45,6 @@ gboolean gimp_help_locale_parse (GimpHelpLocale *locale,
|
||||||
const gchar *uri,
|
const gchar *uri,
|
||||||
const gchar *help_domain,
|
const gchar *help_domain,
|
||||||
GimpHelpProgress *progress,
|
GimpHelpProgress *progress,
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue