summaryrefslogtreecommitdiff
path: root/src/screenshot-filename-builder.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-03-26 09:07:39 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-04-16 14:25:49 -0400
commitb9585034c541b88da8f4b6f9896f6e054a129a04 (patch)
tree6f127af730cb31aeea3a8fd3f0f0f30bd88db8f9 /src/screenshot-filename-builder.c
parent7a67741093a5ea0229dd7e7bfae7032f625ee3bd (diff)
downloadgnome-screenshot-b9585034c541b88da8f4b6f9896f6e054a129a04.tar.gz
screenshot: consolidate filename creation error paths
Diffstat (limited to 'src/screenshot-filename-builder.c')
-rw-r--r--src/screenshot-filename-builder.c41
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;
+ }
}
}