[gimp/gimp-2-8] Bug 752582 - Error message when refreshing resources without...



commit 53e5084a361523c810851e43cb2d1d2781133e1c
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jul 21 19:24:45 2015 +0200

    Bug 752582 - Error message when refreshing resources without...
    
    ...a writable resource directory
    
    gimp_data_factory_data_save(): don't warn about a missing writable
    directory if there is nothing to save.
    
    (cherry picked from commit 16fa1b722dc4d440766a021edbfb0c72d1fdac76)

 app/core/gimpdatafactory.c |   52 +++++++++++++++++++++++++++----------------
 1 files changed, 33 insertions(+), 19 deletions(-)
---
diff --git a/app/core/gimpdatafactory.c b/app/core/gimpdatafactory.c
index 3dc66fc..07eeef3 100644
--- a/app/core/gimpdatafactory.c
+++ b/app/core/gimpdatafactory.c
@@ -411,6 +411,7 @@ gimp_data_factory_data_refresh (GimpDataFactory *factory,
 void
 gimp_data_factory_data_save (GimpDataFactory *factory)
 {
+  GList  *dirty = NULL;
   GList  *list;
   gchar  *writable_dir;
   GError *error = NULL;
@@ -420,6 +421,22 @@ gimp_data_factory_data_save (GimpDataFactory *factory)
   if (gimp_container_is_empty (factory->priv->container))
     return;
 
+  for (list = GIMP_LIST (factory->priv->container)->list;
+       list;
+       list = g_list_next (list))
+    {
+      GimpData *data = list->data;
+
+      if (gimp_data_is_dirty (data) &&
+          gimp_data_is_writable (data))
+        {
+          dirty = g_list_prepend (dirty, data);
+        }
+    }
+
+  if (! dirty)
+    return;
+
   writable_dir = gimp_data_factory_get_save_dir (factory, &error);
 
   if (! writable_dir)
@@ -429,40 +446,37 @@ gimp_data_factory_data_save (GimpDataFactory *factory)
                     error->message);
       g_clear_error (&error);
 
+      g_list_free (dirty);
+
       return;
     }
 
-  for (list = GIMP_LIST (factory->priv->container)->list;
-       list;
-       list = g_list_next (list))
+  for (list = dirty; list; list = g_list_next (list))
     {
-      GimpData *data = list->data;
+      GimpData *data  = list->data;
+      GError   *error = NULL;
 
       if (! gimp_data_get_filename (data))
         gimp_data_create_filename (data, writable_dir);
 
-      if (gimp_data_is_dirty (data) &&
-          gimp_data_is_writable (data))
+      if (! gimp_data_save (data, &error))
         {
-          GError *error = NULL;
-
-          if (! gimp_data_save (data, &error))
+          /*  check if there actually was an error (no error
+           *  means the data class does not implement save)
+           */
+          if (error)
             {
-              /*  check if there actually was an error (no error
-               *  means the data class does not implement save)
-               */
-              if (error)
-                {
-                  gimp_message (factory->priv->gimp, NULL, GIMP_MESSAGE_ERROR,
-                                _("Failed to save data:\n\n%s"),
-                                error->message);
-                  g_clear_error (&error);
-                }
+              gimp_message (factory->priv->gimp, NULL, GIMP_MESSAGE_ERROR,
+                            _("Failed to save data:\n\n%s"),
+                            error->message);
+              g_clear_error (&error);
             }
         }
     }
 
   g_free (writable_dir);
+
+  g_list_free (dirty);
 }
 
 static void


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