[gimp] Issue #3070: CRITICAL when converting to Indexed image.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #3070: CRITICAL when converting to Indexed image.
- Date: Wed, 17 Jul 2019 11:13:02 +0000 (UTC)
commit 03f645cd2d048a2a7cd280d961e32babd76c4b16
Author: Jehan <jehan girinstud io>
Date: Wed Jul 17 13:08:06 2019 +0200
Issue #3070: CRITICAL when converting to Indexed image.
Revert the previous commit 786686a541 and comes up with a better fix.
Let's actually change the image base type and add its colormap as close
as possible without any GUI calls in-between. I also add an explicative
comment so that people are aware of this call proximity requirement to
avoid future problems when the code gets remixed.
It should be better than hacking around with exception in GUI code, and
should (hopefully) avoid other similar bugs.
app/core/gimpimage-convert-indexed.c | 24 ++++++++++++++++--------
app/display/gimpdisplayshell-title.c | 14 +-------------
2 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpimage-convert-indexed.c b/app/core/gimpimage-convert-indexed.c
index 8560ed8183..7897b79719 100644
--- a/app/core/gimpimage-convert-indexed.c
+++ b/app/core/gimpimage-convert-indexed.c
@@ -810,14 +810,6 @@ gimp_image_convert_indexed (GimpImage *image,
/* Set the new base type */
old_type = gimp_image_get_base_type (image);
- g_object_set (image, "base-type", GIMP_INDEXED, NULL);
-
- /* when converting from GRAY, always convert to the new type's
- * builtin profile
- */
- if (old_type == GIMP_GRAY)
- dest_profile = gimp_image_get_builtin_color_profile (image);
-
/* Build histogram if necessary. */
rgb_to_lab_fish = babl_fish (babl_format ("R'G'B' float"),
babl_format ("CIE Lab float"));
@@ -950,6 +942,16 @@ gimp_image_convert_indexed (GimpImage *image,
if (quantobj->second_pass_init)
quantobj->second_pass_init (quantobj);
+ /* Set the base type just before we also set the colormap. In
+ * particular we must not let any GUI code in-between (like progress
+ * update) in order to avoid any context switch. Some various pieces
+ * of the code are relying on proper image state, and an indexed image
+ * without a colormap is not a proper state (it will also have neither
+ * babl format nor profile).
+ * See #3070.
+ */
+ g_object_set (image, "base-type", GIMP_INDEXED, NULL);
+
/* Set the generated palette on the image, we need it to
* convert the layers. We optionally remove duplicate entries
* after the layer conversion.
@@ -969,6 +971,12 @@ gimp_image_convert_indexed (GimpImage *image,
quantobj->actual_number_of_colors, TRUE);
}
+ /* when converting from GRAY, always convert to the new type's
+ * builtin profile
+ */
+ if (old_type == GIMP_GRAY)
+ dest_profile = gimp_image_get_builtin_color_profile (image);
+
/* Convert all layers */
for (list = all_layers;
list;
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index b6cf541dd9..6078222f3c 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -81,28 +81,16 @@ static gboolean
gimp_display_shell_update_title_idle (gpointer data)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
- GimpImage *image;
shell->title_idle_id = 0;
- image = gimp_display_get_image (shell->display);
- if (image)
+ if (gimp_display_get_image (shell->display))
{
GimpDisplayConfig *config = shell->display->config;
gchar title[MAX_TITLE_BUF];
gchar status[MAX_TITLE_BUF];
gint len;
- /* This is a ugly hack to prevent this function to be called while
- * an image is being converted to indexed (which may happen as
- * various context switch happen during progress update). In such
- * edge case, we end up in an in-between time where the image is
- * seamingly broken as it has no format (hence no profile either).
- */
- if (gimp_image_get_base_type (image) == GIMP_INDEXED &&
- ! gimp_image_get_layer_format (image, FALSE))
- return FALSE;
-
/* format the title */
len = gimp_display_shell_format_title (shell, title, sizeof (title),
config->image_title_format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]