[gimp] app: fix crash in the newly added GimpDisplayShell render_cache code



commit d93e92870333955d187fdbfbf2a2ceb4ff97b07f
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jul 17 12:16:57 2019 +0200

    app: fix crash in the newly added GimpDisplayShell render_cache code
    
    Must initialize shell->render_buf_width,height before realize(), so
    move the code to gimp_display_shell_init(), it doesn't depend on the
    shell being realized.

 app/display/gimpdisplayshell-callbacks.c | 23 -----------------------
 app/display/gimpdisplayshell.c           | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 7b2e281a29..3875e4902e 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -83,7 +83,6 @@ gimp_display_shell_canvas_realize (GtkWidget        *canvas,
   GimpCanvasPaddingMode  padding_mode;
   GimpRGB                padding_color;
   GtkAllocation          allocation;
-  const gchar           *env;
 
   gtk_widget_grab_focus (canvas);
 
@@ -115,28 +114,6 @@ gimp_display_shell_canvas_realize (GtkWidget        *canvas,
 
   /*  allow shrinking  */
   gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
-
-  shell->render_buf_width  = 256;
-  shell->render_buf_height = 256;
-
-  env = g_getenv ("GIMP_DISPLAY_RENDER_BUF_SIZE");
-
-  if (env)
-    {
-      gint width  = atoi (env);
-      gint height = width;
-
-      env = strchr (env, 'x');
-      if (env)
-        height = atoi (env + 1);
-
-      if (width  > 0 && width  <= 8192 &&
-          height > 0 && height <= 8192)
-        {
-          shell->render_buf_width  = width;
-          shell->render_buf_height = height;
-        }
-    }
 }
 
 static gboolean
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index a1075cb66f..e46b89b781 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -303,6 +303,8 @@ gimp_color_managed_iface_init (GimpColorManagedInterface *iface)
 static void
 gimp_display_shell_init (GimpDisplayShell *shell)
 {
+  const gchar *env;
+
   shell->options            = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
   shell->fullscreen_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
   shell->no_image_options   = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE, NULL);
@@ -327,6 +329,28 @@ gimp_display_shell_init (GimpDisplayShell *shell)
   shell->filter_profile    = gimp_babl_get_builtin_color_profile (GIMP_RGB,
                                                                   GIMP_TRC_NON_LINEAR);
 
+  shell->render_buf_width  = 256;
+  shell->render_buf_height = 256;
+
+  env = g_getenv ("GIMP_DISPLAY_RENDER_BUF_SIZE");
+
+  if (env)
+    {
+      gint width  = atoi (env);
+      gint height = width;
+
+      env = strchr (env, 'x');
+      if (env)
+        height = atoi (env + 1);
+
+      if (width  > 0 && width  <= 8192 &&
+          height > 0 && height <= 8192)
+        {
+          shell->render_buf_width  = width;
+          shell->render_buf_height = height;
+        }
+    }
+
   shell->motion_buffer   = gimp_motion_buffer_new ();
 
   g_signal_connect (shell->motion_buffer, "stroke",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]