[gimp] Bug 793630 - GIMP does not create 'gradients' directory on first run.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 793630 - GIMP does not create 'gradients' directory on first run.
- Date: Wed, 21 Feb 2018 13:52:09 +0000 (UTC)
commit 6c93228718e5fe2efe63ae4e5cef131dab4ef446
Author: Jehan <jehan girinstud io>
Date: Wed Feb 21 14:39:43 2018 +0100
Bug 793630 - GIMP does not create 'gradients' directory on first run.
I had to shuffle a bit the order of initialization since we were
creating a folder for the crash logs, as well as one for the backups a
bit too early. So now I move errors_init() after configuration folder
creation/migration, and I create both these folders in this function
(especially since gimp_init_signal_handlers() is run even earlier).
For this later reason, I also check for backtrace_file and backup_path
being allocated in gimp_eek() since it is also possible for signals
happening before errors_init(). In such a case, we will simply bypass
the GUI error handler (terminal error handler still possible) and the
backup (anyway there is nothing to backup at this point).
I could also try to create these 2 directories at the last second, when
needed. But since we are trying to do the strict minimum during crash
handling, it is better to do whatever can be done earlier.
app/app.c | 13 +++++++--
app/errors.c | 81 +++++++++++++++++++++++++++++++-------------------------
app/signals.c | 3 --
3 files changed, 55 insertions(+), 42 deletions(-)
---
diff --git a/app/app.c b/app/app.c
index 58b60d2..2bc6f68 100644
--- a/app/app.c
+++ b/app/app.c
@@ -248,9 +248,6 @@ app_run (const gchar *full_prog_name,
gimp_cpu_accel_set_use (use_cpu_accel);
- errors_init (gimp, full_prog_name, use_debug_handler,
- stack_trace_mode, backtrace_file);
-
/* Check if the user's gimp_directory exists
*/
gimpdir = gimp_directory_file (NULL);
@@ -275,6 +272,16 @@ app_run (const gchar *full_prog_name,
g_object_unref (gimpdir);
+ /* Initialize the error handling after creating/migrating the config
+ * directory because it will create some folders for backup and crash
+ * logs in advance. Therefore running this before
+ * gimp_user_install_new() would break migration as well as initial
+ * folder creations.
+ */
+ errors_init (gimp, full_prog_name, use_debug_handler,
+ stack_trace_mode, backtrace_file);
+
+
gimp_load_config (gimp, alternate_system_gimprc, alternate_gimprc);
/* run the late-stage sanity check. it's important that this check is run
diff --git a/app/errors.c b/app/errors.c
index e6401b4..6072462 100644
--- a/app/errors.c
+++ b/app/errors.c
@@ -131,9 +131,15 @@ errors_init (Gimp *gimp,
use_debug_handler = _use_debug_handler ? TRUE : FALSE;
stack_trace_mode = _stack_trace_mode;
full_prog_name = g_strdup (_full_prog_name);
- backtrace_file = g_strdup (_backtrace_file);
+
+ /* Create parent directories for both the crash and backup files. */
+ backtrace_file = g_path_get_dirname (_backtrace_file);
backup_path = g_build_filename (gimp_directory (), "backups", NULL);
+ g_mkdir_with_parents (backtrace_file, S_IRUSR | S_IWUSR | S_IXUSR);
+ g_free (backtrace_file);
+ backtrace_file = g_strdup (_backtrace_file);
+
g_mkdir_with_parents (backup_path, S_IRUSR | S_IWUSR | S_IXUSR);
g_free (backup_path);
backup_path = g_build_filename (gimp_directory (), "backups",
@@ -287,7 +293,8 @@ gimp_eek (const gchar *reason,
{
#ifndef GIMP_CONSOLE_COMPILATION
if (debug_policy != GIMP_DEBUG_POLICY_NEVER &&
- ! the_errors_gimp->no_interface)
+ ! the_errors_gimp->no_interface &&
+ backtrace_file)
{
FILE *fd;
gboolean has_backtrace = TRUE;
@@ -390,42 +397,44 @@ gimp_eek (const gchar *reason,
* Nevertheless in various test cases, I had successful backups XCF of
* the work in progress. Yeah!
*/
+ if (backup_path)
+ {
+ /* The index of 'XXX' in backup_path string. */
+ num_idx = strlen (backup_path) - 7;
+
+ iter = gimp_get_image_iter (the_errors_gimp);
+ for (; iter && i < 1000; iter = iter->next)
+ {
+ GimpImage *image = iter->data;
+ GimpItem *item;
- /* The index of 'XXX' in backup_path string. */
- num_idx = strlen (backup_path) - 7;
+ if (! gimp_image_is_dirty (image))
+ continue;
- iter = gimp_get_image_iter (the_errors_gimp);
- for (; iter && i < 1000; iter = iter->next)
- {
- GimpImage *image = iter->data;
- GimpItem *item;
-
- if (! gimp_image_is_dirty (image))
- continue;
-
- item = GIMP_ITEM (gimp_image_get_active_drawable (image));
-
- /* This is a trick because we want to avoid any memory
- * allocation when the process is abnormally terminated.
- * We just assume that you'll never have more than 1000 images
- * open (which is already far fetched).
- */
- backup_path[num_idx + 2] = '0' + (i % 10);
- backup_path[num_idx + 1] = '0' + ((i/10) % 10);
- backup_path[num_idx] = '0' + ((i/100) % 10);
-
- /* Saving. */
- gimp_pdb_execute_procedure_by_name (the_errors_gimp->pdb,
- gimp_get_user_context (the_errors_gimp),
- NULL, NULL,
- "gimp-xcf-save",
- GIMP_TYPE_INT32, 0,
- GIMP_TYPE_IMAGE_ID, gimp_image_get_ID (image),
- GIMP_TYPE_DRAWABLE_ID, gimp_item_get_ID (item),
- G_TYPE_STRING, backup_path,
- G_TYPE_STRING, backup_path,
- G_TYPE_NONE);
- i++;
+ item = GIMP_ITEM (gimp_image_get_active_drawable (image));
+
+ /* This is a trick because we want to avoid any memory
+ * allocation when the process is abnormally terminated.
+ * We just assume that you'll never have more than 1000 images
+ * open (which is already far fetched).
+ */
+ backup_path[num_idx + 2] = '0' + (i % 10);
+ backup_path[num_idx + 1] = '0' + ((i/10) % 10);
+ backup_path[num_idx] = '0' + ((i/100) % 10);
+
+ /* Saving. */
+ gimp_pdb_execute_procedure_by_name (the_errors_gimp->pdb,
+ gimp_get_user_context (the_errors_gimp),
+ NULL, NULL,
+ "gimp-xcf-save",
+ GIMP_TYPE_INT32, 0,
+ GIMP_TYPE_IMAGE_ID, gimp_image_get_ID (image),
+ GIMP_TYPE_DRAWABLE_ID, gimp_item_get_ID (item),
+ G_TYPE_STRING, backup_path,
+ G_TYPE_STRING, backup_path,
+ G_TYPE_NONE);
+ i++;
+ }
}
exit (EXIT_FAILURE);
diff --git a/app/signals.c b/app/signals.c
index 75da822..f8aa54c 100644
--- a/app/signals.c
+++ b/app/signals.c
@@ -64,9 +64,6 @@ gimp_init_signal_handlers (gchar **backtrace_file)
dir = g_build_filename (gimp_directory (), "CrashLog", NULL);
#endif
- /* Ensure the path exists. */
- g_mkdir_with_parents (dir, 0700);
-
time (&t);
filename = g_strdup_printf ("%s-crash-%" G_GUINT64_FORMAT ".txt",
PACKAGE_NAME, t);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]