[gnome-screenshot] screenshot: consolidate filename creation error paths



commit b9585034c541b88da8f4b6f9896f6e054a129a04
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 26 09:07:39 2012 -0400

    screenshot: consolidate filename creation error paths

 src/screenshot-filename-builder.c |   41 +++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/screenshot-filename-builder.c b/src/screenshot-filename-builder.c
index 04bb75c..e143694 100644
--- a/src/screenshot-filename-builder.c
+++ b/src/screenshot-filename-builder.c
@@ -161,6 +161,22 @@ async_existence_job_free (AsyncExistenceJob *job)
 }
 
 static gboolean
+prepare_next_cycle (AsyncExistenceJob *job)
+{
+  gboolean res = FALSE;
+
+  if (job->type != (NUM_TESTS - 1))
+    {
+      (job->type)++;
+      job->iteration = 0;
+
+      res = TRUE;
+    }
+
+  return res;
+}
+
+static gboolean
 try_check_file (GIOSchedulerJob *io_job,
                 GCancellable *cancellable,
                 gpointer data)
@@ -212,8 +228,13 @@ retry:
 
           if (!g_file_query_exists (parent, NULL))
             {
-              (job->type)++;
-              job->iteration = 0;
+              if (!prepare_next_cycle (job))
+                {
+                  retval = NULL;
+
+                  g_object_unref (parent);
+                  goto out;
+                }
 
               g_object_unref (file);
               g_object_unref (parent);
@@ -233,20 +254,18 @@ retry:
            * accessible.
            */
           g_free (uri);
-          if (job->type == (NUM_TESTS - 1))
-            {
-              retval = NULL;
-              goto out;
-            }
-          else
-            {
-              (job->type)++;
-              job->iteration = 0;
 
+          if (prepare_next_cycle (job))
+            {
               g_error_free (error);
               g_object_unref (file);
               goto retry;
             }
+          else
+            {
+              retval = NULL;
+              goto out;
+            }
         }
     }
 



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