[gnome-builder] style: use g_autoptr and g_steal_pointer with GError
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] style: use g_autoptr and g_steal_pointer with GError
- Date: Wed, 6 Dec 2017 11:55:27 +0000 (UTC)
commit bd3e3ea1aa1d3f83fe00e7e67d1b3f89783a9ae5
Author: Christian Hergert <chergert redhat com>
Date: Wed Dec 6 03:54:01 2017 -0800
style: use g_autoptr and g_steal_pointer with GError
This changes all our uses of g_task_return_error() to use
g_steal_pointer() and g_autoptr(GError). This is how I want to
see new code written.
It also cleans up things here and there as I came across it.
src/libide/application/ide-application.c | 4 +-
src/libide/buffers/ide-buffer-manager.c | 18 ++++---
src/libide/buffers/ide-unsaved-files.c | 9 +--
.../ide-buildconfig-configuration-provider.c | 17 +++---
src/libide/buildui/ide-build-tool.c | 8 ++--
src/libide/directory/ide-directory-vcs.c | 4 +-
src/libide/editor/ide-editor-workbench-addin.c | 4 +-
.../editorconfig/ide-editorconfig-file-settings.c | 4 +-
src/libide/gsettings/ide-language-defaults.c | 20 ++++---
src/libide/projects/ide-project.c | 38 +++++++-------
src/libide/runner/ide-runner.c | 37 +++++---------
src/libide/subprocess/ide-breakout-subprocess.c | 21 +++-----
src/libide/template/ide-template-base.c | 53 +++++++++-----------
src/libide/util/ide-async-helper.c | 4 +-
src/libide/util/ide-glib.c | 3 +-
src/libide/workbench/ide-workbench-open.c | 4 +-
src/libide/workers/ide-worker-manager.c | 4 +-
src/libide/workers/ide-worker-process.c | 4 +-
src/plugins/autotools/ide-autotools-build-system.c | 11 ++---
src/plugins/autotools/ide-makecache.c | 28 +++++-----
src/plugins/clang/ide-clang-diagnostic-provider.c | 4 +-
src/plugins/clang/ide-clang-service.c | 8 ++--
.../gbp-create-project-genesis-addin.c | 5 +-
.../create-project/gbp-create-project-tool.c | 16 +++---
.../create-project/gbp-create-project-widget.c | 8 ++--
src/plugins/ctags/ide-ctags-index.c | 4 +-
src/plugins/ctags/ide-ctags-service.c | 4 +-
src/plugins/ctags/ide-ctags-symbol-resolver.c | 35 ++++++-------
src/plugins/flatpak/gbp-flatpak-clone-widget.c | 29 +++++------
.../flatpak/gbp-flatpak-configuration-provider.c | 12 ++--
src/plugins/flatpak/gbp-flatpak-genesis-addin.c | 4 +-
.../gettext/ide-gettext-diagnostic-provider.c | 14 +++---
src/plugins/git/ide-git-buffer-change-monitor.c | 4 +-
src/plugins/git/ide-git-clone-widget.c | 6 +-
src/plugins/git/ide-git-genesis-addin.c | 4 +-
src/plugins/git/ide-git-vcs-initializer.c | 6 +-
.../ide-gca-diagnostic-provider.c | 28 +++++-----
.../gnome-code-assistance/ide-gca-service.c | 8 ++--
src/plugins/sysprof/gbp-sysprof-workbench-addin.c | 12 ++---
src/plugins/terminal/gb-terminal-view-actions.c | 8 ++--
src/plugins/xml-pack/ide-xml-diagnostic-provider.c | 4 +-
src/plugins/xml-pack/ide-xml-service.c | 20 ++++----
src/plugins/xml-pack/ide-xml-symbol-resolver.c | 4 +-
src/plugins/xml-pack/ide-xml-tree-builder.c | 8 ++--
44 files changed, 257 insertions(+), 293 deletions(-)
---
diff --git a/src/libide/application/ide-application.c b/src/libide/application/ide-application.c
index 0049751..51beb69 100644
--- a/src/libide/application/ide-application.c
+++ b/src/libide/application/ide-application.c
@@ -715,7 +715,7 @@ ide_application_get_worker_cb (GObject *object,
{
IdeWorkerManager *worker_manager = (IdeWorkerManager *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GDBusProxy *proxy;
g_assert (IDE_IS_WORKER_MANAGER (worker_manager));
@@ -723,7 +723,7 @@ ide_application_get_worker_cb (GObject *object,
proxy = ide_worker_manager_get_worker_finish (worker_manager, result, &error);
if (proxy == NULL)
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, proxy, g_object_unref);
}
diff --git a/src/libide/buffers/ide-buffer-manager.c b/src/libide/buffers/ide-buffer-manager.c
index 799dd8f..e7db555 100644
--- a/src/libide/buffers/ide-buffer-manager.c
+++ b/src/libide/buffers/ide-buffer-manager.c
@@ -586,6 +586,8 @@ ide_buffer_manager_load_file__load_cb (GObject *object,
g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
+
+ g_clear_error (&error);
}
gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (state->buffer), FALSE);
@@ -641,8 +643,8 @@ ide_buffer_manager__load_file_query_info_cb (GObject *object,
GFile *file = (GFile *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(GFileInfo) file_info = NULL;
+ g_autoptr(GError) error = NULL;
LoadState *state;
- GError *error = NULL;
gsize size = 0;
gboolean create_new_view = FALSE;
@@ -660,13 +662,14 @@ ide_buffer_manager__load_file_query_info_cb (GObject *object,
file_info = g_file_query_info_finish (file, result, &error);
- if (!file_info)
+ if (file_info == NULL)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
+ g_clear_error (&error);
}
else
{
@@ -988,6 +991,7 @@ ide_buffer_manager_save_file__save_cb (GObject *object,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
GtkSourceFileSaver *saver = (GtkSourceFileSaver *)object;
IdeBufferManager *self;
IdeUnsavedFiles *unsaved_files;
@@ -997,7 +1001,6 @@ ide_buffer_manager_save_file__save_cb (GObject *object,
GFile *gfile;
GFile *old_gfile;
SaveState *state;
- GError *error = NULL;
g_assert (GTK_SOURCE_IS_FILE_SAVER (saver));
g_assert (G_IS_TASK (task));
@@ -1014,7 +1017,7 @@ ide_buffer_manager_save_file__save_cb (GObject *object,
/* Complete the save request */
if (!gtk_source_file_saver_save_finish (saver, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -1065,7 +1068,7 @@ ide_buffer_manager_save_file__load_settings_cb (GObject *object,
GtkSourceNewlineType newline_type;
const GtkSourceEncoding *encoding;
const gchar *charset;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -1076,7 +1079,7 @@ ide_buffer_manager_save_file__load_settings_cb (GObject *object,
if (!file_settings)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -2180,6 +2183,7 @@ ide_buffer_manager_apply_edits_buffer_loaded (GObject *object,
g_task_return_error (task, g_steal_pointer (&error));
return;
}
+ g_clear_error (&error);
}
/* Nothing to do if we already failed */
diff --git a/src/libide/buffers/ide-unsaved-files.c b/src/libide/buffers/ide-unsaved-files.c
index 4b8c1b1..895630f 100644
--- a/src/libide/buffers/ide-unsaved-files.c
+++ b/src/libide/buffers/ide-unsaved-files.c
@@ -233,12 +233,9 @@ ide_unsaved_files_save_worker (GTask *task,
}
if (!g_file_set_contents (manifest_path, manifest->str, manifest->len, &write_error))
- {
- g_task_return_error (task, write_error);
- IDE_EXIT;
- }
-
- g_task_return_boolean (task, TRUE);
+ g_task_return_error (task, g_steal_pointer (&write_error));
+ else
+ g_task_return_boolean (task, TRUE);
IDE_EXIT;
}
diff --git a/src/libide/buildconfig/ide-buildconfig-configuration-provider.c
b/src/libide/buildconfig/ide-buildconfig-configuration-provider.c
index 71a22ab..35adf7f 100644
--- a/src/libide/buildconfig/ide-buildconfig-configuration-provider.c
+++ b/src/libide/buildconfig/ide-buildconfig-configuration-provider.c
@@ -61,14 +61,14 @@ ide_buildconfig_configuration_provider_save_cb (GObject *object,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GFile *file = (GFile *)object;
g_assert (G_IS_FILE (file));
g_assert (G_IS_ASYNC_RESULT (result));
if (!g_file_replace_contents_finish (file, result, NULL, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
}
@@ -85,13 +85,12 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
g_auto(GStrv) groups = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(GBytes) bytes = NULL;
+ g_autoptr(GError) error = NULL;
gchar *data;
- gsize length;
+ gsize length = 0;
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
- GError *error = NULL;
- guint i;
IDE_ENTRY;
@@ -130,7 +129,7 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
group_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- for (i = 0; i < self->configurations->len; i++)
+ for (guint i = 0; i < self->configurations->len; i++)
{
IdeConfiguration *configuration = g_ptr_array_index (self->configurations, i);
IdeEnvironment *environment;
@@ -209,7 +208,7 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
*/
if (NULL != (groups = g_key_file_get_groups (self->key_file, NULL)))
{
- for (i = 0; groups [i]; i++)
+ for (guint i = 0; groups [i]; i++)
{
if (!g_hash_table_contains (group_names, groups [i]))
g_key_file_remove_group (self->key_file, groups [i], NULL);
@@ -218,7 +217,7 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
if (NULL == (data = g_key_file_to_data (self->key_file, &length, &error)))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -231,7 +230,7 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
G_FILE_CREATE_NONE,
cancellable,
ide_buildconfig_configuration_provider_save_cb,
- g_object_ref (task));
+ g_steal_pointer (&task));
IDE_EXIT;
}
diff --git a/src/libide/buildui/ide-build-tool.c b/src/libide/buildui/ide-build-tool.c
index bc41a30..d0b1fc4 100644
--- a/src/libide/buildui/ide-build-tool.c
+++ b/src/libide/buildui/ide-build-tool.c
@@ -176,7 +176,7 @@ ide_build_tool_new_context_cb (GObject *object,
IdeBuildManager *build_manager;
IdeBuildPipeline *pipeline;
GCancellable *cancellable;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (G_IS_TASK (task));
@@ -186,7 +186,7 @@ ide_build_tool_new_context_cb (GObject *object,
if (context == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -260,8 +260,8 @@ ide_build_tool_run_async (IdeApplicationTool *tool,
g_autoptr(GFile) project_file = NULL;
g_autoptr(GOptionContext) opt_context = NULL;
g_auto(GStrv) strv = NULL;
+ g_autoptr(GError) error = NULL;
gboolean clean = FALSE;
- GError *error = NULL;
const GOptionEntry entries[] = {
{ "clean", 'c', 0, G_OPTION_ARG_NONE, &clean,
N_("Clean the project") },
@@ -295,7 +295,7 @@ ide_build_tool_run_async (IdeApplicationTool *tool,
if (!g_option_context_parse_strv (opt_context, &strv, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/libide/directory/ide-directory-vcs.c b/src/libide/directory/ide-directory-vcs.c
index 4327fcf..221f8ee 100644
--- a/src/libide/directory/ide-directory-vcs.c
+++ b/src/libide/directory/ide-directory-vcs.c
@@ -162,8 +162,8 @@ ide_directory_vcs_init_worker (GTask *task,
{
IdeDirectoryVcs *self = source_object;
g_autoptr(GFileInfo) file_info = NULL;
+ g_autoptr(GError) error = NULL;
GFile *file = task_data;
- GError *error = NULL;
GFileType file_type;
g_assert (IDE_IS_DIRECTORY_VCS (self));
@@ -177,7 +177,7 @@ ide_directory_vcs_init_worker (GTask *task,
if (file_info == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/libide/editor/ide-editor-workbench-addin.c b/src/libide/editor/ide-editor-workbench-addin.c
index a3ddc9e..6da9b74 100644
--- a/src/libide/editor/ide-editor-workbench-addin.c
+++ b/src/libide/editor/ide-editor-workbench-addin.c
@@ -323,7 +323,7 @@ ide_editor_workbench_addin_open_cb (GObject *object,
IdeEditorWorkbenchAddin *self;
g_autoptr(IdeBuffer) buffer = NULL;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
const gchar *fragment;
OpenFileTaskData *open_file_task_data;
IdeUri *uri;
@@ -341,7 +341,7 @@ ide_editor_workbench_addin_open_cb (GObject *object,
if (buffer == NULL)
{
IDE_TRACE_MSG ("%s", error->message);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/libide/editorconfig/ide-editorconfig-file-settings.c
b/src/libide/editorconfig/ide-editorconfig-file-settings.c
index a3346c5..369022f 100644
--- a/src/libide/editorconfig/ide-editorconfig-file-settings.c
+++ b/src/libide/editorconfig/ide-editorconfig-file-settings.c
@@ -57,10 +57,10 @@ ide_editorconfig_file_settings_init_worker (GTask *task,
GCancellable *cancellable)
{
GFile *file = task_data;
+ g_autoptr(GError) error = NULL;
GHashTableIter iter;
GHashTable *ht;
gpointer k, v;
- GError *error = NULL;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_EDITORCONFIG_FILE_SETTINGS (source_object));
@@ -71,7 +71,7 @@ ide_editorconfig_file_settings_init_worker (GTask *task,
if (!ht)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/libide/gsettings/ide-language-defaults.c b/src/libide/gsettings/ide-language-defaults.c
index e16f4c4..6ed34ff 100644
--- a/src/libide/gsettings/ide-language-defaults.c
+++ b/src/libide/gsettings/ide-language-defaults.c
@@ -216,10 +216,10 @@ ide_language_defaults_init_worker (GTask *task,
g_autofree gchar *version_dir = NULL;
g_autoptr(GBytes) defaults = NULL;
g_autoptr(GKeyFile) key_file = NULL;
+ g_autoptr(GError) error = NULL;
gint global_version;
- gboolean ret;
- GError *error = NULL;
gint current_version;
+ gboolean ret;
IDE_ENTRY;
@@ -237,7 +237,7 @@ ide_language_defaults_init_worker (GTask *task,
if (current_version < 0)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
goto failure;
}
@@ -245,7 +245,7 @@ ide_language_defaults_init_worker (GTask *task,
if (!defaults)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
goto failure;
}
@@ -258,7 +258,7 @@ ide_language_defaults_init_worker (GTask *task,
if (!ret)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
goto failure;
}
@@ -274,17 +274,19 @@ ide_language_defaults_init_worker (GTask *task,
global_version = g_key_file_get_integer (key_file, "global", "version", &error);
- if ((global_version == 0) && error)
+ if (global_version == 0 && error != NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
goto failure;
}
+ g_clear_error (&error);
+
if (global_version > current_version)
{
if (!ide_language_defaults_migrate (key_file, current_version, global_version, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
goto failure;
}
@@ -308,7 +310,7 @@ ide_language_defaults_init_worker (GTask *task,
if (!g_file_set_contents (version_path, version_contents, -1, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
goto failure;
}
}
diff --git a/src/libide/projects/ide-project.c b/src/libide/projects/ide-project.c
index dba8887..4cf934c 100644
--- a/src/libide/projects/ide-project.c
+++ b/src/libide/projects/ide-project.c
@@ -466,8 +466,8 @@ rename_file_free (gpointer data)
if (op != NULL)
{
- g_object_unref (op->new_file);
- g_object_unref (op->orig_file);
+ g_clear_object (&op->new_file);
+ g_clear_object (&op->orig_file);
g_slice_free (RenameFile, op);
}
}
@@ -475,7 +475,7 @@ rename_file_free (gpointer data)
static gboolean
emit_file_renamed (gpointer data)
{
- g_autoptr(GTask) task = data;
+ GTask *task = data;
IdeProject *project;
RenameFile *rf;
@@ -510,7 +510,7 @@ ide_project_rename_file_worker (GTask *task,
IdeContext *context;
IdeVcs *vcs;
RenameFile *op = task_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GFile *workdir;
g_assert (IDE_IS_PROJECT (self));
@@ -526,11 +526,9 @@ ide_project_rename_file_worker (GTask *task,
#ifdef IDE_ENABLE_TRACE
{
- gchar *old_path = g_file_get_uri (op->orig_file);
- gchar *new_path = g_file_get_uri (op->new_file);
+ g_autofree gchar *old_path = g_file_get_uri (op->orig_file);
+ g_autofree gchar *new_path = g_file_get_uri (op->new_file);
IDE_TRACE_MSG ("Renaming %s to %s", old_path, new_path);
- g_free (old_path);
- g_free (new_path);
}
#endif
@@ -548,7 +546,7 @@ ide_project_rename_file_worker (GTask *task,
if (!g_file_query_exists (parent, cancellable) &&
!g_file_make_directory_with_parents (parent, cancellable, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -560,11 +558,14 @@ ide_project_rename_file_worker (GTask *task,
NULL,
&error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
- g_timeout_add (0, emit_file_renamed, g_object_ref (task));
+ g_idle_add_full (G_PRIORITY_LOW,
+ emit_file_renamed,
+ g_object_ref (task),
+ g_object_unref);
g_task_return_boolean (task, TRUE);
}
@@ -738,15 +739,12 @@ ide_project_trash_file_async (IdeProject *self,
subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error);
if (subprocess == NULL)
- {
- g_task_return_error (task, g_steal_pointer (&error));
- IDE_EXIT;
- }
-
- ide_subprocess_wait_check_async (subprocess,
- cancellable,
- ide_project_trash_file__wait_check_cb,
- g_steal_pointer (&task));
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ ide_subprocess_wait_check_async (subprocess,
+ cancellable,
+ ide_project_trash_file__wait_check_cb,
+ g_steal_pointer (&task));
IDE_EXIT;
}
diff --git a/src/libide/runner/ide-runner.c b/src/libide/runner/ide-runner.c
index 55c3f79..d6b8632 100644
--- a/src/libide/runner/ide-runner.c
+++ b/src/libide/runner/ide-runner.c
@@ -135,7 +135,7 @@ ide_runner_run_wait_cb (GObject *object,
IdeSubprocess *subprocess = (IdeSubprocess *)object;
IdeRunnerPrivate *priv;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IdeRunner *self;
IDE_ENTRY;
@@ -155,7 +155,7 @@ ide_runner_run_wait_cb (GObject *object,
if (!ide_subprocess_wait_finish (subprocess, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -221,7 +221,7 @@ ide_runner_real_run_async (IdeRunner *self,
const gchar *identifier;
IdeContext *context;
IdeRuntime *runtime;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -304,7 +304,7 @@ ide_runner_real_run_async (IdeRunner *self,
if (subprocess == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}
@@ -880,18 +880,15 @@ ide_runner_posthook_cb (GObject *object,
{
IdeRunnerAddin *addin = (IdeRunnerAddin *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_RUNNER_ADDIN (addin));
g_assert (G_IS_ASYNC_RESULT (result));
if (!ide_runner_addin_posthook_finish (addin, result, &error))
- {
- g_task_return_error (task, error);
- return;
- }
-
- ide_runner_tick_posthook (task);
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ ide_runner_tick_posthook (task);
}
static void
@@ -934,12 +931,9 @@ ide_runner_run_cb (GObject *object,
g_assert (G_IS_TASK (task));
if (!IDE_RUNNER_GET_CLASS (self)->run_finish (self, result, &error))
- {
- g_task_return_error (task, g_steal_pointer (&error));
- IDE_EXIT;
- }
-
- ide_runner_tick_posthook (task);
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ ide_runner_tick_posthook (task);
IDE_EXIT;
}
@@ -979,12 +973,9 @@ ide_runner_prehook_cb (GObject *object,
g_assert (G_IS_TASK (task));
if (!ide_runner_addin_prehook_finish (addin, result, &error))
- {
- g_task_return_error (task, g_steal_pointer (&error));
- IDE_EXIT;
- }
-
- ide_runner_tick_prehook (task);
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ ide_runner_tick_prehook (task);
IDE_EXIT;
}
diff --git a/src/libide/subprocess/ide-breakout-subprocess.c b/src/libide/subprocess/ide-breakout-subprocess.c
index ef2c44c..3671f78 100644
--- a/src/libide/subprocess/ide-breakout-subprocess.c
+++ b/src/libide/subprocess/ide-breakout-subprocess.c
@@ -671,15 +671,14 @@ ide_subprocess_communicate_made_progress (GObject *source_object,
{
CommunicateState *state;
IdeBreakoutSubprocess *subprocess;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GTask) task = user_data;
gpointer source;
- GTask *task;
IDE_ENTRY;
g_assert (source_object != NULL);
- task = user_data;
subprocess = g_task_get_source_object (task);
state = g_task_get_task_data (task);
source = source_object;
@@ -690,18 +689,17 @@ ide_subprocess_communicate_made_progress (GObject *source_object,
source == state->stdout_buf ||
source == state->stderr_buf)
{
- if (g_output_stream_splice_finish ((GOutputStream*) source, result, &error) == -1)
+ if (g_output_stream_splice_finish (source, result, &error) == -1)
goto out;
- if (source == state->stdout_buf ||
- source == state->stderr_buf)
+ if (source == state->stdout_buf || source == state->stderr_buf)
{
/* This is a memory stream, so it can't be cancelled or return
* an error really.
*/
if (state->add_nul)
{
- gsize bytes_written;
+ gsize bytes_written = 0;
if (!g_output_stream_write_all (source, "\0", 1, &bytes_written, NULL, &error))
goto out;
}
@@ -717,7 +715,7 @@ ide_subprocess_communicate_made_progress (GObject *source_object,
g_assert_not_reached ();
out:
- if (error)
+ if (error != NULL)
{
/* Only report the first error we see.
*
@@ -728,19 +726,14 @@ ide_subprocess_communicate_made_progress (GObject *source_object,
{
state->reported_error = TRUE;
g_cancellable_cancel (state->cancellable);
- ide_g_task_return_error_from_main (task, error);
+ ide_g_task_return_error_from_main (task, g_steal_pointer (&error));
}
- else
- g_error_free (error);
}
else if (state->outstanding_ops == 0)
{
ide_g_task_return_boolean_from_main (task, TRUE);
}
- /* And drop the original ref */
- g_object_unref (task);
-
IDE_EXIT;
}
diff --git a/src/libide/template/ide-template-base.c b/src/libide/template/ide-template-base.c
index c9cf780..ffbe594 100644
--- a/src/libide/template/ide-template-base.c
+++ b/src/libide/template/ide-template-base.c
@@ -69,29 +69,25 @@ ide_template_base_mkdirs_worker (GTask *task,
{
IdeTemplateBase *self = source_object;
IdeTemplateBasePrivate *priv = ide_template_base_get_instance_private (self);
- GError *error = NULL;
- guint i;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TEMPLATE_BASE (self));
- for (i = 0; i < priv->files->len; i++)
+ for (guint i = 0; i < priv->files->len; i++)
{
+ FileExpansion *fexp = &g_array_index (priv->files, FileExpansion, i);
g_autoptr(GFile) directory = NULL;
- FileExpansion *fexp;
+ g_autoptr(GError) error = NULL;
- fexp = &g_array_index (priv->files, FileExpansion, i);
directory = g_file_get_parent (fexp->destination);
if (!g_file_make_directory_with_parents (directory, cancellable, &error))
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
-
- g_clear_error (&error);
}
}
@@ -269,17 +265,16 @@ ide_template_base_parse_worker (GTask *task,
{
IdeTemplateBase *self = source_object;
IdeTemplateBasePrivate *priv = ide_template_base_get_instance_private (self);
- guint i;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TEMPLATE_BASE (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- for (i = 0; i < priv->files->len; i++)
+ for (guint i = 0; i < priv->files->len; i++)
{
FileExpansion *fexp = &g_array_index (priv->files, FileExpansion, i);
g_autoptr(TmplTemplate) template = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
if (fexp->template != NULL)
continue;
@@ -288,7 +283,7 @@ ide_template_base_parse_worker (GTask *task,
if (!tmpl_template_parse_file (template, fexp->file, cancellable, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -331,7 +326,7 @@ ide_template_base_replace_cb (GObject *object,
{
GFile *file = (GFile *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
ExpansionTask *expansion;
FileExpansion *fexp = NULL;
guint i;
@@ -353,9 +348,7 @@ ide_template_base_replace_cb (GObject *object,
if (!g_file_replace_contents_finish (file, result, NULL, &error))
{
if (!g_task_get_completed (task))
- g_task_return_error (task, error);
- else
- g_error_free (error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -421,7 +414,7 @@ ide_template_base_expand (GTask *task)
now = g_get_monotonic_time ())
{
FileExpansion *fexp;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (expansion->index <= expansion->files->len);
@@ -439,7 +432,7 @@ ide_template_base_expand (GTask *task)
if (fexp->result == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return G_SOURCE_REMOVE;
}
@@ -497,13 +490,13 @@ ide_template_base_expand_parse_cb (GObject *object,
{
IdeTemplateBase *self = (IdeTemplateBase *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_TEMPLATE_BASE (self));
if (!ide_template_base_parse_finish (self, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -521,21 +514,21 @@ ide_template_base_expand_mkdirs_cb (GObject *object,
{
IdeTemplateBase *self = (IdeTemplateBase *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
+ GCancellable *cancellable;
g_assert (IDE_IS_TEMPLATE_BASE (self));
g_assert (G_IS_TASK (task));
- if (!ide_template_base_mkdirs_finish (self, result, &error))
- {
- g_task_return_error (task, error);
- return;
- }
+ cancellable = g_task_get_cancellable (task);
- ide_template_base_parse_async (self,
- g_task_get_cancellable (task),
- ide_template_base_expand_parse_cb,
- g_object_ref (task));
+ if (!ide_template_base_mkdirs_finish (self, result, &error))
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ ide_template_base_parse_async (self,
+ cancellable,
+ ide_template_base_expand_parse_cb,
+ g_steal_pointer (&task));
}
void
diff --git a/src/libide/util/ide-async-helper.c b/src/libide/util/ide-async-helper.c
index f64f56f..ee84408 100644
--- a/src/libide/util/ide-async-helper.c
+++ b/src/libide/util/ide-async-helper.c
@@ -24,8 +24,8 @@ ide_async_helper_cb (GObject *object,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
GPtrArray *funcs;
- GError *error = NULL;
g_return_if_fail (G_IS_TASK (task));
g_return_if_fail (G_IS_TASK (result));
@@ -34,7 +34,7 @@ ide_async_helper_cb (GObject *object,
if (!g_task_propagate_boolean (G_TASK (result), &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/libide/util/ide-glib.c b/src/libide/util/ide-glib.c
index c41cadc..861c2be 100644
--- a/src/libide/util/ide-glib.c
+++ b/src/libide/util/ide-glib.c
@@ -63,8 +63,7 @@ do_return (gpointer user_data)
default:
if (state->type == G_TYPE_ERROR)
{
- g_task_return_error (state->task, state->u.v_error);
- state->u.v_error = NULL;
+ g_task_return_error (state->task, g_steal_pointer (&state->u.v_error));
break;
}
diff --git a/src/libide/workbench/ide-workbench-open.c b/src/libide/workbench/ide-workbench-open.c
index 76dc4db..4e93916 100644
--- a/src/libide/workbench/ide-workbench-open.c
+++ b/src/libide/workbench/ide-workbench-open.c
@@ -443,9 +443,9 @@ ide_workbench_open_project_cb (GObject *object,
{
g_autoptr(GTask) task = user_data;
g_autoptr(IdeContext) context = NULL;
+ g_autoptr(GError) error = NULL;
IdeWorkbench *workbench;
guint32 present_time;
- GError *error = NULL;
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
@@ -454,7 +454,7 @@ ide_workbench_open_project_cb (GObject *object,
if (context == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/libide/workers/ide-worker-manager.c b/src/libide/workers/ide-worker-manager.c
index cffc459..664af81 100644
--- a/src/libide/workers/ide-worker-manager.c
+++ b/src/libide/workers/ide-worker-manager.c
@@ -226,8 +226,8 @@ ide_worker_manager_get_worker_cb (GObject *object,
{
IdeWorkerProcess *worker_process = (IdeWorkerProcess *)object;
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
GDBusProxy *proxy;
- GError *error = NULL;
IDE_ENTRY;
@@ -237,7 +237,7 @@ ide_worker_manager_get_worker_cb (GObject *object,
proxy = ide_worker_process_get_proxy_finish (worker_process, result, &error);
if (proxy == NULL)
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, proxy, g_object_unref);
diff --git a/src/libide/workers/ide-worker-process.c b/src/libide/workers/ide-worker-process.c
index 652358a..79e699f 100644
--- a/src/libide/workers/ide-worker-process.c
+++ b/src/libide/workers/ide-worker-process.c
@@ -366,7 +366,7 @@ ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self,
GTask *task)
{
GDBusProxy *proxy;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -390,7 +390,7 @@ ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self,
error = g_error_new_literal (G_IO_ERROR,
G_IO_ERROR_PROXY_FAILED,
"IdeWorker returned NULL and did not set an error.");
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
diff --git a/src/plugins/autotools/ide-autotools-build-system.c
b/src/plugins/autotools/ide-autotools-build-system.c
index 13d24cd..7bb8801 100644
--- a/src/plugins/autotools/ide-autotools-build-system.c
+++ b/src/plugins/autotools/ide-autotools-build-system.c
@@ -653,18 +653,15 @@ parse_cb (GObject *object,
{
IdeAutotoolsBuildSystem *self = (IdeAutotoolsBuildSystem *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_return_if_fail (IDE_IS_AUTOTOOLS_BUILD_SYSTEM (self));
g_return_if_fail (G_IS_TASK (task));
if (!ide_autotools_build_system_parse_finish (self, result, &error))
- {
- g_task_return_error (task, error);
- return;
- }
-
- g_task_return_boolean (task, TRUE);
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ g_task_return_boolean (task, TRUE);
}
static void
diff --git a/src/plugins/autotools/ide-makecache.c b/src/plugins/autotools/ide-makecache.c
index 33984b5..989f1f3 100644
--- a/src/plugins/autotools/ide-makecache.c
+++ b/src/plugins/autotools/ide-makecache.c
@@ -635,7 +635,7 @@ ide_makecache_get_file_flags_worker (GTask *task,
const gchar *subdir;
const gchar *targetstr;
const gchar *relpath;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gchar **lines;
gchar **ret = NULL;
gchar *tmp;
@@ -689,7 +689,7 @@ ide_makecache_get_file_flags_worker (GTask *task,
if (launcher == NULL)
{
g_assert (error != NULL);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -703,7 +703,7 @@ ide_makecache_get_file_flags_worker (GTask *task,
if (subprocess == NULL)
{
g_assert (error != NULL);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -711,7 +711,7 @@ ide_makecache_get_file_flags_worker (GTask *task,
if (!ide_subprocess_communicate_utf8 (subprocess, NULL, NULL, &stdoutstr, NULL, &error))
{
g_assert (error != NULL);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -922,7 +922,7 @@ ide_makecache_get_file_flags__get_targets_cb (GObject *object,
g_autoptr(GPtrArray) targets = NULL;
g_autoptr(GTask) task = user_data;
FileFlagsLookup *lookup;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -931,7 +931,7 @@ ide_makecache_get_file_flags__get_targets_cb (GObject *object,
if (!(targets = ide_makecache_get_file_targets_finish (self, result, &error)))
{
g_assert (error != NULL);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -1198,13 +1198,13 @@ ide_makecache_get_file_targets__task_cache_get_cb (GObject *object,
{
DzlTaskCache *cache = (DzlTaskCache *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GPtrArray *ret;
if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
{
g_assert (error != NULL);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
}
else
g_task_return_pointer (task, ret, (GDestroyNotify)g_ptr_array_unref);
@@ -1269,13 +1269,13 @@ ide_makecache_get_file_flags__task_cache_get_cb (GObject *object,
{
DzlTaskCache *cache = (DzlTaskCache *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gchar **ret;
if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
{
g_assert (error != NULL);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
}
else
g_task_return_pointer (task, ret, (GDestroyNotify)g_strfreev);
@@ -1460,7 +1460,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
IdeContext *context;
IdeRuntime *runtime;
GFile *build_dir = task_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gchar *line;
gsize line_len;
IdeLineReader reader;
@@ -1539,7 +1539,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
if (makedirs == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}
@@ -1584,7 +1584,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
*/
if (NULL == (subprocess = ide_subprocess_launcher_spawn (launcher, NULL, &error)))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}
@@ -1594,7 +1594,7 @@ ide_makecache_get_build_targets_worker (GTask *task,
*/
if (!ide_subprocess_communicate_utf8 (subprocess, PRINT_VARS, NULL, &stdout_buf, NULL, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}
diff --git a/src/plugins/clang/ide-clang-diagnostic-provider.c
b/src/plugins/clang/ide-clang-diagnostic-provider.c
index f8ec7e0..ce8dc14 100644
--- a/src/plugins/clang/ide-clang-diagnostic-provider.c
+++ b/src/plugins/clang/ide-clang-diagnostic-provider.c
@@ -51,16 +51,16 @@ get_translation_unit_cb (GObject *object,
IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) tu = NULL;
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
IdeDiagnostics *diagnostics;
IdeFile *target;
GFile *gfile;
- GError *error = NULL;
tu = ide_clang_service_get_translation_unit_finish (service, result, &error);
if (!tu)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/clang/ide-clang-service.c b/src/plugins/clang/ide-clang-service.c
index 51c7fc5..75e2017 100644
--- a/src/plugins/clang/ide-clang-service.c
+++ b/src/plugins/clang/ide-clang-service.c
@@ -433,15 +433,15 @@ ide_clang_service_unit_completed_cb (GObject *object,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
gpointer ret;
- GError *error = NULL;
g_assert (IDE_IS_CLANG_SERVICE (object));
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
if (!(ret = g_task_propagate_pointer (G_TASK (result), &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, ret, g_object_unref);
}
@@ -530,12 +530,12 @@ ide_clang_service_get_translation_unit_cb (GObject *object,
DzlTaskCache *cache = (DzlTaskCache *)object;
g_autoptr(IdeClangTranslationUnit) ret = NULL;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (DZL_IS_TASK_CACHE (cache));
if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&ret), g_object_unref);
}
diff --git a/src/plugins/create-project/gbp-create-project-genesis-addin.c
b/src/plugins/create-project/gbp-create-project-genesis-addin.c
index 9d59783..eacc393 100644
--- a/src/plugins/create-project/gbp-create-project-genesis-addin.c
+++ b/src/plugins/create-project/gbp-create-project-genesis-addin.c
@@ -165,13 +165,14 @@ gbp_create_project_genesis_addin_run_cb (GObject *object,
{
GbpCreateProjectWidget *widget = (GbpCreateProjectWidget *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (G_IS_TASK (task));
+ g_assert (G_IS_ASYNC_RESULT (result));
g_assert (GBP_IS_CREATE_PROJECT_WIDGET (widget));
if (!gbp_create_project_widget_create_finish (widget, result, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
}
diff --git a/src/plugins/create-project/gbp-create-project-tool.c
b/src/plugins/create-project/gbp-create-project-tool.c
index 507dd12..1ab1c8c 100644
--- a/src/plugins/create-project/gbp-create-project-tool.c
+++ b/src/plugins/create-project/gbp-create-project-tool.c
@@ -242,14 +242,14 @@ vcs_init_cb (GObject *object,
{
IdeVcsInitializer *vcs = (IdeVcsInitializer *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_VCS_INITIALIZER (vcs));
g_assert (G_IS_TASK (task));
g_assert (G_IS_ASYNC_RESULT (result));
if (!ide_vcs_initializer_initialize_finish (vcs, result, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_int (task, 0);
}
@@ -263,7 +263,7 @@ extract_cb (GObject *object,
g_autoptr(GTask) task = user_data;
GbpCreateProjectTool *self;
g_autoptr(IdeVcsInitializer) vcs = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_PROJECT_TEMPLATE (template));
g_assert (G_IS_ASYNC_RESULT (result));
@@ -274,7 +274,7 @@ extract_cb (GObject *object,
if (!ide_project_template_expand_finish (template, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -345,7 +345,7 @@ gbp_create_project_tool_run_async (IdeApplicationTool *tool,
g_autoptr(GTask) task = NULL;
g_autoptr(GHashTable) params = NULL;
const gchar *name;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (GBP_IS_CREATE_PROJECT_TOOL (self));
@@ -356,7 +356,7 @@ gbp_create_project_tool_run_async (IdeApplicationTool *tool,
if (!gbp_create_project_tool_parse (self, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -379,7 +379,7 @@ gbp_create_project_tool_run_async (IdeApplicationTool *tool,
if (!validate_name (self, name, &error))
{
g_printerr ("%s\n", error->message);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -399,7 +399,7 @@ gbp_create_project_tool_run_async (IdeApplicationTool *tool,
if (!extract_params (self, params, &error))
{
g_printerr ("%s\n", error->message);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/create-project/gbp-create-project-widget.c
b/src/plugins/create-project/gbp-create-project-widget.c
index 17d430f..620f7f3 100644
--- a/src/plugins/create-project/gbp-create-project-widget.c
+++ b/src/plugins/create-project/gbp-create-project-widget.c
@@ -489,14 +489,14 @@ init_vcs_cb (GObject *object,
GbpCreateProjectWidget *self;
IdeWorkbench *workbench;
GFile *project_file;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
if (!ide_vcs_initializer_initialize_finish (vcs, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -525,7 +525,7 @@ extract_cb (GObject *object,
PeasEngine *engine;
PeasPluginInfo *plugin_info;
GFile *project_file;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
/* To keep the UI simple, we only support git from
* the creation today. However, at the time of writing
@@ -541,7 +541,7 @@ extract_cb (GObject *object,
if (!ide_project_template_expand_finish (template, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/ctags/ide-ctags-index.c b/src/plugins/ctags/ide-ctags-index.c
index 8cdd39d..23edac7 100644
--- a/src/plugins/ctags/ide-ctags-index.c
+++ b/src/plugins/ctags/ide-ctags-index.c
@@ -190,8 +190,8 @@ ide_ctags_index_build_index (GTask *task,
GCancellable *cancellable)
{
IdeCtagsIndex *self = source_object;
+ g_autoptr(GError) error = NULL;
IdeLineReader reader;
- GError *error = NULL;
GArray *index = NULL;
gchar *contents = NULL;
gchar *line;
@@ -254,7 +254,7 @@ failure:
g_clear_pointer (&index, g_array_unref);
if (error != NULL)
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_new_error (task,
G_IO_ERROR,
diff --git a/src/plugins/ctags/ide-ctags-service.c b/src/plugins/ctags/ide-ctags-service.c
index 30b6c87..7b7cd62 100644
--- a/src/plugins/ctags/ide-ctags-service.c
+++ b/src/plugins/ctags/ide-ctags-service.c
@@ -61,13 +61,13 @@ ide_ctags_service_build_index_init_cb (GObject *object,
{
IdeCtagsIndex *index = (IdeCtagsIndex *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_CTAGS_INDEX (index));
g_assert (G_IS_TASK (task));
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (index), result, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else if (ide_ctags_index_get_is_empty (index))
g_task_return_new_error (task,
G_IO_ERROR,
diff --git a/src/plugins/ctags/ide-ctags-symbol-resolver.c b/src/plugins/ctags/ide-ctags-symbol-resolver.c
index e56e147..e8b1245 100644
--- a/src/plugins/ctags/ide-ctags-symbol-resolver.c
+++ b/src/plugins/ctags/ide-ctags-symbol-resolver.c
@@ -170,9 +170,9 @@ regex_worker (GTask *task,
IdeCtagsSymbolResolver *self = source_object;
LookupSymbol *lookup = task_data;
g_autoptr(GRegex) regex = NULL;
+ g_autoptr(GError) error = NULL;
g_autofree gchar *pattern = NULL;
- GMatchInfo *match_info = NULL;
- GError *error = NULL;
+ g_autoptr(GMatchInfo) match_info = NULL;
const gchar *data;
gsize length;
@@ -185,7 +185,7 @@ regex_worker (GTask *task,
if (lookup->mapped == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -202,7 +202,7 @@ regex_worker (GTask *task,
if (!(regex = g_regex_new (pattern, G_REGEX_MULTILINE, 0, &error)))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -215,34 +215,29 @@ regex_worker (GTask *task,
if (g_match_info_fetch_pos (match_info, 0, &begin, &end))
{
- IdeSymbol *symbol;
+ g_autoptr(IdeSymbol) symbol = NULL;
gint line = 0;
gint line_offset = 0;
calculate_offset (data, length, begin, &line, &line_offset);
symbol = create_symbol (self, lookup->entry, line, line_offset, begin);
- g_task_return_pointer (task, symbol, (GDestroyNotify)ide_symbol_unref);
-
- g_match_info_free (match_info);
+ g_task_return_pointer (task,
+ g_steal_pointer (&symbol),
+ (GDestroyNotify)ide_symbol_unref);
return;
}
}
- g_match_info_free (match_info);
-
if (error != NULL)
- {
- g_task_return_error (task, error);
- return;
- }
-
- g_task_return_new_error (task,
- G_IO_ERROR,
- G_IO_ERROR_NOT_FOUND,
- "Failed to locate symbol \"%s\"",
- lookup->entry->name);
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_FOUND,
+ "Failed to locate symbol \"%s\"",
+ lookup->entry->name);
}
static gboolean
diff --git a/src/plugins/flatpak/gbp-flatpak-clone-widget.c b/src/plugins/flatpak/gbp-flatpak-clone-widget.c
index 9108263..0b67f1d 100644
--- a/src/plugins/flatpak/gbp-flatpak-clone-widget.c
+++ b/src/plugins/flatpak/gbp-flatpak-clone-widget.c
@@ -312,8 +312,8 @@ gbp_flatpak_clone_widget_worker (GTask *task,
g_autofree gchar *manifest_hash = NULL;
g_autofree gchar *runtime_id = NULL;
g_autofree gchar *manifest_file_name = NULL;
+ g_autoptr(GError) error = NULL;
gsize manifest_contents_len;
- GError *error = NULL;
GType git_callbacks_type;
guint i;
@@ -330,7 +330,7 @@ gbp_flatpak_clone_widget_worker (GTask *task,
if (repository == NULL &&
!g_error_matches (error, GGIT_ERROR, GGIT_ERROR_NOTFOUND))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -361,7 +361,7 @@ gbp_flatpak_clone_widget_worker (GTask *task,
repository = ggit_repository_clone (uristr, req->destination, clone_options, &error);
if (repository == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -371,7 +371,7 @@ gbp_flatpak_clone_widget_worker (GTask *task,
parsed_rev = ggit_repository_revparse (repository, req->src->branch, &error);
if (parsed_rev == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -381,7 +381,7 @@ gbp_flatpak_clone_widget_worker (GTask *task,
if (error != NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
}
@@ -398,10 +398,10 @@ gbp_flatpak_clone_widget_worker (GTask *task,
self->strip_components,
&error);
if (error != NULL)
- {
- g_task_return_error (task, error);
- return;
- }
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ return;
+ }
}
for (i = 0; req->src->patches[i]; i++)
@@ -411,7 +411,7 @@ gbp_flatpak_clone_widget_worker (GTask *task,
self->strip_components,
&error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
}
@@ -421,10 +421,9 @@ gbp_flatpak_clone_widget_worker (GTask *task,
manifest_file_name = g_strjoin (".", self->id, "json", NULL);
dst = g_file_get_child (req->project_file,
manifest_file_name);
- if (!g_file_copy (src, dst, G_FILE_COPY_OVERWRITE, NULL,
- NULL, NULL, &error))
+ if (!g_file_copy (src, dst, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -577,11 +576,11 @@ gbp_flatpak_clone_widget_clone_async (GbpFlatpakCloneWidget *self,
g_autoptr(GTask) task = NULL;
g_autoptr(GSettings) settings = NULL;
g_autoptr(GFile) destination = NULL;
+ g_autoptr(GError) error = NULL;
g_autofree gchar *path = NULL;
g_autofree gchar *projects_dir = NULL;
DownloadRequest *req;
ModuleSource *src;
- GError *error = NULL;
g_return_if_fail (GBP_IS_FLATPAK_CLONE_WIDGET (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
@@ -591,7 +590,7 @@ gbp_flatpak_clone_widget_clone_async (GbpFlatpakCloneWidget *self,
src = get_source (self, &error);
if (src == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
b/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
index e01ab8f..5a5a2a4 100644
--- a/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
@@ -61,7 +61,6 @@ gbp_flatpak_configuration_provider_save_worker (GTask *task,
GCancellable *cancellable)
{
GbpFlatpakConfigurationProvider *self = source_object;
- GError *error = NULL;
IDE_ENTRY;
@@ -88,6 +87,7 @@ gbp_flatpak_configuration_provider_save_worker (GTask *task,
g_auto(GStrv) new_config_opts = NULL;
g_auto(GStrv) new_runtime_parts = NULL;
g_auto(GStrv) new_environ = NULL;
+ g_autoptr(GError) error = NULL;
g_autofree gchar *primary_module_regex_str = NULL;
g_autofree gchar *primary_module_right_curly_brace = NULL;
g_autofree gchar *right_curly_brace_line = NULL;
@@ -128,7 +128,7 @@ gbp_flatpak_configuration_provider_save_worker (GTask *task,
file_stream = g_file_read (manifest, NULL, &error);
if (file_stream == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -182,7 +182,7 @@ gbp_flatpak_configuration_provider_save_worker (GTask *task,
line = g_data_input_stream_read_line_utf8 (data_stream, NULL, NULL, &error);
if (error != NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -459,7 +459,7 @@ gbp_flatpak_configuration_provider_save_worker (GTask *task,
next_line = g_data_input_stream_read_line_utf8 (data_stream, NULL, NULL, &error);
if (error != NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
if (g_str_has_prefix (next_line, primary_module_right_curly_brace))
@@ -558,7 +558,7 @@ gbp_flatpak_configuration_provider_save_worker (GTask *task,
cancellable,
&error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
}
@@ -1020,8 +1020,8 @@ gbp_flatpak_configuration_provider_load_cb (GObject *object,
gpointer user_data)
{
GbpFlatpakConfigurationProvider *self = (GbpFlatpakConfigurationProvider *)object;
+ g_autoptr(GError) error = NULL;
GPtrArray *ret;
- GError *error = NULL;
guint i;
g_autoptr(GTask) task = user_data;
diff --git a/src/plugins/flatpak/gbp-flatpak-genesis-addin.c b/src/plugins/flatpak/gbp-flatpak-genesis-addin.c
index 3663837..7b03b03 100644
--- a/src/plugins/flatpak/gbp-flatpak-genesis-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-genesis-addin.c
@@ -131,13 +131,13 @@ gbp_flatpak_genesis_addin_run_cb (GObject *object,
{
GbpFlatpakCloneWidget *widget = (GbpFlatpakCloneWidget *)object;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (G_IS_TASK (task));
g_assert (GBP_IS_FLATPAK_CLONE_WIDGET (widget));
if (!gbp_flatpak_clone_widget_clone_finish (widget, result, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
}
diff --git a/src/plugins/gettext/ide-gettext-diagnostic-provider.c
b/src/plugins/gettext/ide-gettext-diagnostic-provider.c
index 1657e48..bd08ea3 100644
--- a/src/plugins/gettext/ide-gettext-diagnostic-provider.c
+++ b/src/plugins/gettext/ide-gettext-diagnostic-provider.c
@@ -179,7 +179,7 @@ get_diagnostics_cb (GObject *source_object,
DzlTaskCache *cache = DZL_TASK_CACHE (source_object);
g_autoptr(GTask) task = user_data;
g_autoptr(IdeGettextDiagnostics) diags = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (DZL_IS_TASK_CACHE (cache));
g_assert (G_IS_TASK (task));
@@ -187,7 +187,7 @@ get_diagnostics_cb (GObject *source_object,
diags = dzl_task_cache_get_finish (cache, res, &error);
if (diags == NULL)
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&diags), g_object_unref);
}
@@ -285,8 +285,8 @@ subprocess_wait_cb (GObject *object,
g_autoptr(GDataInputStream) stderr_data_input = NULL;
GInputStream *stderr_input = NULL;
g_autoptr(IdeGettextDiagnostics) diags = NULL;
+ g_autoptr(GError) error = NULL;
TranslationUnit *unit;
- GError *error = NULL;
g_assert (G_IS_SUBPROCESS (subprocess));
g_assert (G_IS_TASK (task));
@@ -297,7 +297,7 @@ subprocess_wait_cb (GObject *object,
if (!g_subprocess_wait_finish (subprocess, res, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -401,7 +401,7 @@ populate_cache (DzlTaskCache *cache,
TranslationUnit *unit;
IdeFile *file = (IdeFile *)key;
GCancellable *cancellable;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GPtrArray *args;
g_assert (DZL_IS_TASK_CACHE (cache));
@@ -432,7 +432,7 @@ populate_cache (DzlTaskCache *cache,
if (!ide_unsaved_file_persist (unsaved_file, cancellable, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -472,7 +472,7 @@ populate_cache (DzlTaskCache *cache,
if (subprocess == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/git/ide-git-buffer-change-monitor.c b/src/plugins/git/ide-git-buffer-change-monitor.c
index f88ec8f..a21b8ef 100644
--- a/src/plugins/git/ide-git-buffer-change-monitor.c
+++ b/src/plugins/git/ide-git-buffer-change-monitor.c
@@ -671,14 +671,14 @@ ide_git_buffer_change_monitor_worker (gpointer data)
while ((task = g_async_queue_pop (queue)))
{
IdeGitBufferChangeMonitor *self;
+ g_autoptr(GError) error = NULL;
DiffTask *diff;
- GError *error = NULL;
self = g_task_get_source_object (task);
diff = g_task_get_task_data (task);
if (!ide_git_buffer_change_monitor_calculate_threaded (self, diff, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_hash_table_ref (diff->state),
(GDestroyNotify)g_hash_table_unref);
diff --git a/src/plugins/git/ide-git-clone-widget.c b/src/plugins/git/ide-git-clone-widget.c
index 4cec5ec..748ea11 100644
--- a/src/plugins/git/ide-git-clone-widget.c
+++ b/src/plugins/git/ide-git-clone-widget.c
@@ -332,13 +332,13 @@ ide_git_clone_widget_worker (GTask *task,
{
g_autofree gchar *uristr = NULL;
IdeGitCloneWidget *self = source_object;
+ g_autoptr(GError) error = NULL;
GgitRepository *repository;
- CloneRequest *req = task_data;
GgitCloneOptions *clone_options;
GgitFetchOptions *fetch_options;
GgitRemoteCallbacks *callbacks;
+ CloneRequest *req = task_data;
IdeProgress *progress;
- GError *error = NULL;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_GIT_CLONE_WIDGET (self));
@@ -372,7 +372,7 @@ ide_git_clone_widget_worker (GTask *task,
if (repository == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/git/ide-git-genesis-addin.c b/src/plugins/git/ide-git-genesis-addin.c
index 5a356d5..ee38a06 100644
--- a/src/plugins/git/ide-git-genesis-addin.c
+++ b/src/plugins/git/ide-git-genesis-addin.c
@@ -130,14 +130,14 @@ ide_git_genesis_addin_run_cb (GObject *object,
gpointer user_data)
{
IdeGitCloneWidget *widget = (IdeGitCloneWidget *)object;
+ g_autoptr(GError) error = NULL;
g_autoptr(GTask) task = user_data;
- GError *error = NULL;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_GIT_CLONE_WIDGET (widget));
if (!ide_git_clone_widget_clone_finish (widget, result, &error))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
}
diff --git a/src/plugins/git/ide-git-vcs-initializer.c b/src/plugins/git/ide-git-vcs-initializer.c
index c3d0e18..9772d5d 100644
--- a/src/plugins/git/ide-git-vcs-initializer.c
+++ b/src/plugins/git/ide-git-vcs-initializer.c
@@ -52,9 +52,9 @@ ide_git_vcs_initializer_initialize_worker (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFile *file = task_data;
g_autoptr(GgitRepository) repository = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
+ GFile *file = task_data;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_GIT_VCS_INITIALIZER (source_object));
@@ -63,7 +63,7 @@ ide_git_vcs_initializer_initialize_worker (GTask *task,
repository = ggit_repository_init_repository (file, FALSE, &error);
if (repository == NULL)
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
}
diff --git a/src/plugins/gnome-code-assistance/ide-gca-diagnostic-provider.c
b/src/plugins/gnome-code-assistance/ide-gca-diagnostic-provider.c
index 85a756b..399b34a 100644
--- a/src/plugins/gnome-code-assistance/ide-gca-diagnostic-provider.c
+++ b/src/plugins/gnome-code-assistance/ide-gca-diagnostic-provider.c
@@ -181,7 +181,7 @@ diagnostics_cb (GObject *object,
GcaDiagnostics *proxy = (GcaDiagnostics *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(GVariant) var = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IdeDiagnostics *diagnostics;
DiagnoseState *state;
@@ -193,7 +193,7 @@ diagnostics_cb (GObject *object,
if (!gca_diagnostics_call_diagnostics_finish (proxy, &var, result, &error))
{
IDE_TRACE_MSG ("%s", error->message);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -214,9 +214,9 @@ get_diag_proxy_cb (GObject *object,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
IdeGcaDiagnosticProvider *self;
GcaDiagnostics *proxy;
- GError *error = NULL;
const gchar *path;
IDE_ENTRY;
@@ -230,7 +230,7 @@ get_diag_proxy_cb (GObject *object,
if (!proxy)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
@@ -252,12 +252,12 @@ parse_cb (GObject *object,
{
GcaService *proxy = (GcaService *)object;
IdeGcaDiagnosticProvider *self;
- DiagnoseState *state;
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
+ g_autofree gchar *document_path = NULL;
GcaDiagnostics *doc_proxy;
+ DiagnoseState *state;
gboolean ret;
- GError *error = NULL;
- g_autofree gchar *document_path = NULL;
IDE_ENTRY;
@@ -279,7 +279,7 @@ parse_cb (GObject *object,
else
{
IDE_TRACE_MSG ("%s", error->message);
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
}
IDE_EXIT;
@@ -340,13 +340,13 @@ get_proxy_cb (GObject *object,
g_autoptr(GTask) task = user_data;
g_autoptr(GVariant) options = NULL;
IdeGcaService *service = (IdeGcaService *)object;
+ g_autofree gchar *path = NULL;
+ g_autoptr(GError) error = NULL;
DiagnoseState *state;
- GcaService *proxy;
const gchar *temp_path;
- GError *error = NULL;
- GFile *gfile;
- g_autofree gchar *path = NULL;
+ GcaService *proxy;
GVariant *cursor = NULL;
+ GFile *gfile;
IDE_ENTRY;
@@ -360,7 +360,7 @@ get_proxy_cb (GObject *object,
if (!proxy)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (cleanup);
}
@@ -382,7 +382,7 @@ get_proxy_cb (GObject *object,
g_task_get_cancellable (task),
&error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (cleanup);
}
diff --git a/src/plugins/gnome-code-assistance/ide-gca-service.c
b/src/plugins/gnome-code-assistance/ide-gca-service.c
index b59375e..1d44397 100644
--- a/src/plugins/gnome-code-assistance/ide-gca-service.c
+++ b/src/plugins/gnome-code-assistance/ide-gca-service.c
@@ -125,9 +125,9 @@ proxy_new_cb (GObject *object,
{
IdeGcaService *self;
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
const gchar *language_id;
GcaService *proxy;
- GError *error = NULL;
g_assert (G_IS_TASK (task));
g_assert (G_IS_ASYNC_RESULT (result));
@@ -138,7 +138,7 @@ proxy_new_cb (GObject *object,
if (!proxy)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -159,11 +159,11 @@ ide_gca_service_get_proxy_async (IdeGcaService *self,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
+ g_autoptr(GError) error = NULL;
g_autofree gchar *name = NULL;
g_autofree gchar *object_path = NULL;
GcaService *proxy;
GDBusConnection *bus;
- GError *error = NULL;
g_return_if_fail (IDE_IS_GCA_SERVICE (self));
g_return_if_fail (language_id);
@@ -186,7 +186,7 @@ ide_gca_service_get_proxy_async (IdeGcaService *self,
if (bus == NULL)
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
diff --git a/src/plugins/sysprof/gbp-sysprof-workbench-addin.c
b/src/plugins/sysprof/gbp-sysprof-workbench-addin.c
index 5279248..a3055ba 100644
--- a/src/plugins/sysprof/gbp-sysprof-workbench-addin.c
+++ b/src/plugins/sysprof/gbp-sysprof-workbench-addin.c
@@ -295,9 +295,9 @@ gbp_sysprof_workbench_addin_open_worker (GTask *task,
{
GbpSysprofWorkbenchAddin *self = source_object;
g_autofree gchar *path = NULL;
+ g_autoptr(GError) error = NULL;
SpCaptureReader *reader;
GFile *file = task_data;
- GError *error = NULL;
g_assert (G_IS_TASK (task));
g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
@@ -307,13 +307,9 @@ gbp_sysprof_workbench_addin_open_worker (GTask *task,
path = g_file_get_path (file);
if (NULL == (reader = sp_capture_reader_new (path, &error)))
- {
- g_assert (error != NULL);
- g_task_return_error (task, error);
- return;
- }
-
- g_task_return_pointer (task, reader, (GDestroyNotify)sp_capture_reader_unref);
+ g_task_return_error (task, g_steal_pointer (&error));
+ else
+ g_task_return_pointer (task, reader, (GDestroyNotify)sp_capture_reader_unref);
}
static void
diff --git a/src/plugins/terminal/gb-terminal-view-actions.c b/src/plugins/terminal/gb-terminal-view-actions.c
index dc97e61..88ec6bd 100644
--- a/src/plugins/terminal/gb-terminal-view-actions.c
+++ b/src/plugins/terminal/gb-terminal-view-actions.c
@@ -71,7 +71,7 @@ save_async (GTask *task,
{
GbTerminalView *view = source_object;
SaveTask *savetask = (SaveTask *)task_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gboolean ret;
g_assert (G_IS_TASK (task));
@@ -103,7 +103,7 @@ save_async (GTask *task,
if (ret)
g_task_return_boolean (task, TRUE);
else
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
}
static void
@@ -116,8 +116,8 @@ gb_terminal_view_actions_save_async (GbTerminalView *view,
{
g_autoptr(GTask) task = NULL;
g_autoptr(GFileOutputStream) output_stream = NULL;
+ g_autoptr(GError) error = NULL;
SaveTask *savetask;
- GError *error = NULL;
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
@@ -135,7 +135,7 @@ gb_terminal_view_actions_save_async (GbTerminalView *view,
g_task_run_in_thread (task, save_async);
}
else
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
}
static void
diff --git a/src/plugins/xml-pack/ide-xml-diagnostic-provider.c
b/src/plugins/xml-pack/ide-xml-diagnostic-provider.c
index f0a6174..73d54c3 100644
--- a/src/plugins/xml-pack/ide-xml-diagnostic-provider.c
+++ b/src/plugins/xml-pack/ide-xml-diagnostic-provider.c
@@ -39,13 +39,13 @@ ide_xml_diagnostic_provider_diagnose_cb (GObject *object,
{
IdeXmlService *service = (IdeXmlService *)object;
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
IdeDiagnostics *diagnostics;
- GError *error = NULL;
IDE_ENTRY;
if (NULL == (diagnostics = ide_xml_service_get_diagnostics_finish (service, result, &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task,
ide_diagnostics_ref (diagnostics),
diff --git a/src/plugins/xml-pack/ide-xml-service.c b/src/plugins/xml-pack/ide-xml-service.c
index 2811db4..565a3d5 100644
--- a/src/plugins/xml-pack/ide-xml-service.c
+++ b/src/plugins/xml-pack/ide-xml-service.c
@@ -58,14 +58,14 @@ ide_xml_service_build_tree_cb2 (GObject *object,
IdeXmlTreeBuilder *tree_builder = (IdeXmlTreeBuilder *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeXmlAnalysis) analysis = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_XML_TREE_BUILDER (tree_builder));
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
if (NULL == (analysis = ide_xml_tree_builder_build_tree_finish (tree_builder, result, &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&analysis), (GDestroyNotify)ide_xml_analysis_unref);
}
@@ -257,14 +257,14 @@ ide_xml_service_get_analysis_cb (GObject *object,
DzlTaskCache *cache = (DzlTaskCache *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeXmlAnalysis) analysis = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (DZL_IS_TASK_CACHE (cache));
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
if (NULL == (analysis = dzl_task_cache_get_finish (cache, result, &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_pointer (task, g_steal_pointer (&analysis), (GDestroyNotify)ide_xml_analysis_unref);
}
@@ -384,14 +384,14 @@ ide_xml_service_get_root_node_cb (GObject *object,
g_autoptr(GTask) task = user_data;
g_autoptr(IdeXmlAnalysis) analysis = NULL;
IdeXmlSymbolNode *root_node;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_XML_SERVICE (self));
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
if (NULL == (analysis = ide_xml_service_get_analysis_finish (self, result, &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
{
root_node = g_object_ref (ide_xml_analysis_get_root_node (analysis));
@@ -498,14 +498,14 @@ ide_xml_service_get_diagnostics_cb (GObject *object,
g_autoptr(GTask) task = user_data;
g_autoptr(IdeXmlAnalysis) analysis = NULL;
IdeDiagnostics *diagnostics;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (IDE_IS_XML_SERVICE (self));
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
if (NULL == (analysis = ide_xml_service_get_analysis_finish (self, result, &error)))
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
else
{
diagnostics = ide_diagnostics_ref (ide_xml_analysis_get_diagnostics (analysis));
@@ -967,7 +967,7 @@ ide_xml_service_get_position_from_cursor_cb (GObject *object,
g_autoptr(GTask) task = state->task;
IdeXmlPosition *position;
IdeXmlAnalysis *analysis = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -981,7 +981,7 @@ ide_xml_service_get_position_from_cursor_cb (GObject *object,
g_task_return_pointer (task, position, g_object_unref);
}
else
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
position_state_free (state);
diff --git a/src/plugins/xml-pack/ide-xml-symbol-resolver.c b/src/plugins/xml-pack/ide-xml-symbol-resolver.c
index 372ee20..7fd4aa3 100644
--- a/src/plugins/xml-pack/ide-xml-symbol-resolver.c
+++ b/src/plugins/xml-pack/ide-xml-symbol-resolver.c
@@ -81,7 +81,7 @@ ide_xml_symbol_resolver_get_symbol_tree_cb (GObject *object,
g_autoptr(GTask) task = user_data;
g_autoptr(IdeXmlSymbolNode) root_node = NULL;
IdeXmlSymbolTree *symbol_tree;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -95,7 +95,7 @@ ide_xml_symbol_resolver_get_symbol_tree_cb (GObject *object,
g_task_return_pointer (task, symbol_tree, g_object_unref);
}
else
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
diff --git a/src/plugins/xml-pack/ide-xml-tree-builder.c b/src/plugins/xml-pack/ide-xml-tree-builder.c
index a35a245..c87e592 100644
--- a/src/plugins/xml-pack/ide-xml-tree-builder.c
+++ b/src/plugins/xml-pack/ide-xml-tree-builder.c
@@ -390,8 +390,8 @@ ide_xml_tree_builder_build_tree_cb2 (GObject *object,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
IdeXmlTreeBuilder *self;
- GError *error = NULL;
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
@@ -401,7 +401,7 @@ ide_xml_tree_builder_build_tree_cb2 (GObject *object,
if (!fetch_schemas_finish (self, result, &error))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -415,9 +415,9 @@ ide_xml_tree_builder_build_tree_cb (GObject *object,
{
IdeXmlTreeBuilder *self;
g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
TreeBuilderState *state;
IdeXmlAnalysis *analysis;
- GError *error = NULL;
g_assert (G_IS_TASK (result));
g_assert (G_IS_TASK (task));
@@ -427,7 +427,7 @@ ide_xml_tree_builder_build_tree_cb (GObject *object,
if (NULL == (analysis = ide_xml_parser_get_analysis_finish (self->parser, result, &error)))
{
- g_task_return_error (task, error);
+ g_task_return_error (task, g_steal_pointer (&error));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]