Commit fc35b276 authored by Christian Hergert's avatar Christian Hergert

libide: port objects with threading to IdeTask

This ports a number of the modules that are using run_in_thread
to using IdeTask so that we can control where finalize of
various associated data happens.
parent c8a58739
Pipeline #6698 failed with stage
in 74 minutes and 36 seconds
......@@ -25,6 +25,7 @@
#include "buildsystem/ide-build-pipeline.h"
#include "buildsystem/ide-build-stage.h"
#include "subprocess/ide-subprocess.h"
#include "threading/ide-task.h"
typedef struct
{
......@@ -32,7 +33,7 @@ typedef struct
IdeBuildLogObserver observer;
gpointer observer_data;
GDestroyNotify observer_data_destroy;
GTask *queued_execute;
IdeTask *queued_execute;
gchar *stdout_path;
GOutputStream *stdout_stream;
gint n_pause;
......@@ -135,7 +136,7 @@ ide_build_stage_real_execute (IdeBuildStage *self,
}
static void
ide_build_stage_real_execute_worker (GTask *task,
ide_build_stage_real_execute_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -144,14 +145,14 @@ ide_build_stage_real_execute_worker (GTask *task,
IdeBuildPipeline *pipeline = task_data;
g_autoptr(GError) error = NULL;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_BUILD_STAGE (self));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
if (IDE_BUILD_STAGE_GET_CLASS (self)->execute (self, pipeline, cancellable, &error))
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
else
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
}
static void
......@@ -161,16 +162,16 @@ ide_build_stage_real_execute_async (IdeBuildStage *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_assert (IDE_IS_BUILD_STAGE (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_build_stage_real_execute_async);
g_task_set_task_data (task, g_object_ref (pipeline), g_object_unref);
g_task_run_in_thread (task, ide_build_stage_real_execute_worker);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_build_stage_real_execute_async);
ide_task_set_task_data (task, g_object_ref (pipeline), g_object_unref);
ide_task_run_in_thread (task, ide_build_stage_real_execute_worker);
}
static gboolean
......@@ -179,9 +180,9 @@ ide_build_stage_real_execute_finish (IdeBuildStage *self,
GError **error)
{
g_assert (IDE_IS_BUILD_STAGE (self));
g_assert (G_IS_TASK (result));
g_assert (IDE_IS_TASK (result));
return g_task_propagate_boolean (G_TASK (result), error);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
const gchar *
......@@ -217,18 +218,18 @@ ide_build_stage_real_clean_async (IdeBuildStage *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_assert (IDE_IS_BUILD_STAGE (self));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ide_build_stage_real_clean_async);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_build_stage_real_clean_async);
ide_build_stage_set_completed (self, FALSE);
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
}
static gboolean
......@@ -236,7 +237,7 @@ ide_build_stage_real_clean_finish (IdeBuildStage *self,
GAsyncResult *result,
GError **error)
{
return g_task_propagate_boolean (G_TASK (result), error);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static gboolean
......@@ -513,7 +514,7 @@ ide_build_stage_execute_async (IdeBuildStage *self,
gpointer user_data)
{
IdeBuildStagePrivate *priv = ide_build_stage_get_instance_private (self);
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_return_if_fail (IDE_IS_BUILD_STAGE (self));
g_return_if_fail (IDE_IS_BUILD_PIPELINE (pipeline));
......@@ -828,16 +829,16 @@ ide_build_stage_unpause_execute_cb (GObject *object,
gpointer user_data)
{
IdeBuildStage *self = (IdeBuildStage *)object;
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_BUILD_STAGE (self));
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
if (!ide_build_stage_execute_finish (self, result, &error))
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
else
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
}
void
......@@ -850,17 +851,17 @@ ide_build_stage_unpause (IdeBuildStage *self)
if (g_atomic_int_dec_and_test (&priv->n_pause) && priv->queued_execute != NULL)
{
g_autoptr(GTask) task = g_steal_pointer (&priv->queued_execute);
GCancellable *cancellable = g_task_get_cancellable (task);
IdeBuildPipeline *pipeline = g_task_get_task_data (task);
g_autoptr(IdeTask) task = g_steal_pointer (&priv->queued_execute);
GCancellable *cancellable = ide_task_get_cancellable (task);
IdeBuildPipeline *pipeline = ide_task_get_task_data (task);
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
if (priv->completed)
{
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
return;
}
......@@ -888,22 +889,22 @@ _ide_build_stage_execute_with_query_async (IdeBuildStage *self,
gpointer user_data)
{
IdeBuildStagePrivate *priv = ide_build_stage_get_instance_private (self);
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_return_if_fail (IDE_IS_BUILD_STAGE (self));
g_return_if_fail (IDE_IS_BUILD_PIPELINE (pipeline));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, _ide_build_stage_execute_with_query_async);
g_task_set_task_data (task, g_object_ref (pipeline), g_object_unref);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, _ide_build_stage_execute_with_query_async);
ide_task_set_task_data (task, g_object_ref (pipeline), g_object_unref);
if (priv->queued_execute != NULL)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_PENDING,
"A build is already in progress");
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_PENDING,
"A build is already in progress");
return;
}
......@@ -925,9 +926,9 @@ _ide_build_stage_execute_with_query_finish (IdeBuildStage *self,
GError **error)
{
g_return_val_if_fail (IDE_IS_BUILD_STAGE (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
void
......@@ -992,7 +993,7 @@ ide_build_stage_clean_finish (IdeBuildStage *self,
GError **error)
{
g_return_val_if_fail (IDE_IS_BUILD_STAGE (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
return IDE_BUILD_STAGE_GET_CLASS (self)->clean_finish (self, result, error);
}
......
......@@ -25,6 +25,7 @@
#include "ide-debug.h"
#include "buildsystem/ide-compile-commands.h"
#include "threading/ide-task.h"
/**
* SECTION:ide-compile-commands
......@@ -140,7 +141,7 @@ ide_compile_commands_new (void)
}
static void
ide_compile_commands_load_worker (GTask *task,
ide_compile_commands_load_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -160,7 +161,7 @@ ide_compile_commands_load_worker (GTask *task,
IDE_ENTRY;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_COMPILE_COMMANDS (self));
g_assert (G_IS_FILE (gfile));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
......@@ -170,7 +171,7 @@ ide_compile_commands_load_worker (GTask *task,
if (!g_file_load_contents (gfile, cancellable, &contents, &len, NULL, &error) ||
!json_parser_load_from_data (parser, contents, len, &error))
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
......@@ -178,10 +179,10 @@ ide_compile_commands_load_worker (GTask *task,
!JSON_NODE_HOLDS_ARRAY (root) ||
NULL == (ar = json_node_get_array (root)))
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Failed to extract commands, invalid json");
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"Failed to extract commands, invalid json");
IDE_EXIT;
}
......@@ -271,7 +272,7 @@ ide_compile_commands_load_worker (GTask *task,
self->info_by_file = g_steal_pointer (&info_by_file);
self->vala_info = g_steal_pointer (&vala_info);
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
IDE_EXIT;
}
......@@ -302,7 +303,7 @@ ide_compile_commands_load (IdeCompileCommands *self,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
gboolean ret;
IDE_ENTRY;
......@@ -314,13 +315,13 @@ ide_compile_commands_load (IdeCompileCommands *self,
self->has_loaded = TRUE;
task = g_task_new (self, cancellable, NULL, NULL);
g_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_source_tag (task, ide_compile_commands_load);
g_task_set_task_data (task, g_object_ref (file), g_object_unref);
task = ide_task_new (self, cancellable, NULL, NULL);
ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_source_tag (task, ide_compile_commands_load);
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
ide_compile_commands_load_worker (task, self, file, cancellable);
ret = g_task_propagate_boolean (task, error);
ret = ide_task_propagate_boolean (task, error);
IDE_RETURN (ret);
}
......@@ -351,7 +352,7 @@ ide_compile_commands_load_async (IdeCompileCommands *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IDE_ENTRY;
......@@ -362,11 +363,11 @@ ide_compile_commands_load_async (IdeCompileCommands *self,
self->has_loaded = TRUE;
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_source_tag (task, ide_compile_commands_load_async);
g_task_set_task_data (task, g_object_ref (file), g_object_unref);
g_task_run_in_thread (task, ide_compile_commands_load_worker);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_source_tag (task, ide_compile_commands_load_async);
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
ide_task_run_in_thread (task, ide_compile_commands_load_worker);
IDE_EXIT;
}
......@@ -396,9 +397,9 @@ ide_compile_commands_load_finish (IdeCompileCommands *self,
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_COMPILE_COMMANDS (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
ret = g_task_propagate_boolean (G_TASK (result), error);
ret = ide_task_propagate_boolean (IDE_TASK (result), error);
IDE_RETURN (ret);
}
......
......@@ -24,6 +24,7 @@
#include "directory/ide-directory-vcs.h"
#include "projects/ide-project.h"
#include "threading/ide-task.h"
struct _IdeDirectoryVcs
{
......@@ -155,7 +156,7 @@ ide_directory_vcs_init (IdeDirectoryVcs *self)
}
static void
ide_directory_vcs_init_worker (GTask *task,
ide_directory_vcs_init_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -177,7 +178,7 @@ ide_directory_vcs_init_worker (GTask *task,
if (file_info == NULL)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
......@@ -193,7 +194,7 @@ ide_directory_vcs_init_worker (GTask *task,
else
self->working_directory = g_file_get_parent (file);
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
}
static void
......@@ -204,7 +205,7 @@ ide_directory_vcs_init_async (GAsyncInitable *initable,
gpointer user_data)
{
IdeDirectoryVcs *self = (IdeDirectoryVcs *)initable;
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IdeContext *context;
GFile *project_file;
......@@ -214,9 +215,9 @@ ide_directory_vcs_init_async (GAsyncInitable *initable,
context = ide_object_get_context (IDE_OBJECT (initable));
project_file = ide_context_get_project_file (context);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_task_data (task, g_object_ref (project_file), g_object_unref);
g_task_run_in_thread (task, ide_directory_vcs_init_worker);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_task_data (task, g_object_ref (project_file), g_object_unref);
ide_task_run_in_thread (task, ide_directory_vcs_init_worker);
}
static gboolean
......@@ -224,13 +225,13 @@ ide_directory_vcs_init_finish (GAsyncInitable *initable,
GAsyncResult *result,
GError **error)
{
GTask *task = (GTask *)result;
IdeTask *task = (IdeTask *)result;
g_return_val_if_fail (IDE_IS_DIRECTORY_VCS (initable), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
g_return_val_if_fail (G_IS_TASK (task), FALSE);
g_return_val_if_fail (IDE_IS_TASK (task), FALSE);
return g_task_propagate_boolean (task, error);
return ide_task_propagate_boolean (task, error);
}
static void
......
......@@ -25,6 +25,7 @@
#include "editorconfig/ide-editorconfig-file-settings.h"
#include "files/ide-file.h"
#include "threading/ide-task.h"
struct _IdeEditorconfigFileSettings
{
......@@ -51,7 +52,7 @@ ide_editorconfig_file_settings_init (IdeEditorconfigFileSettings *self)
}
static void
ide_editorconfig_file_settings_init_worker (GTask *task,
ide_editorconfig_file_settings_init_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -62,7 +63,7 @@ ide_editorconfig_file_settings_init_worker (GTask *task,
GHashTable *ht;
gpointer k, v;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_EDITORCONFIG_FILE_SETTINGS (source_object));
g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
......@@ -71,7 +72,7 @@ ide_editorconfig_file_settings_init_worker (GTask *task,
if (!ht)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
......@@ -123,7 +124,7 @@ ide_editorconfig_file_settings_init_worker (GTask *task,
}
}
g_task_return_boolean (task, TRUE);
ide_task_return_boolean (task, TRUE);
g_hash_table_unref (ht);
}
......@@ -136,7 +137,7 @@ ide_editorconfig_file_settings_init_async (GAsyncInitable *initable,
gpointer user_data)
{
IdeEditorconfigFileSettings *self = (IdeEditorconfigFileSettings *)initable;
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
IdeFile *file;
GFile *gfile = NULL;
......@@ -145,7 +146,7 @@ ide_editorconfig_file_settings_init_async (GAsyncInitable *initable,
g_return_if_fail (IDE_IS_EDITORCONFIG_FILE_SETTINGS (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
task = ide_task_new (self, cancellable, callback, user_data);
file = ide_file_settings_get_file (IDE_FILE_SETTINGS (self));
if (file)
......@@ -153,15 +154,15 @@ ide_editorconfig_file_settings_init_async (GAsyncInitable *initable,
if (!gfile)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
_("No file was provided."));
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
_("No file was provided."));
IDE_EXIT;
}
g_task_set_task_data (task, g_object_ref (gfile), g_object_unref);
g_task_run_in_thread (task, ide_editorconfig_file_settings_init_worker);
ide_task_set_task_data (task, g_object_ref (gfile), g_object_unref);
ide_task_run_in_thread (task, ide_editorconfig_file_settings_init_worker);
IDE_EXIT;
}
......@@ -175,9 +176,9 @@ ide_editorconfig_file_settings_init_finish (GAsyncInitable *initable,
IDE_ENTRY;
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
ret = g_task_propagate_boolean (G_TASK (result), error);
ret = ide_task_propagate_boolean (IDE_TASK (result), error);
IDE_RETURN (ret);
}
......
......@@ -28,6 +28,7 @@
#include "files/ide-file.h"
#include "files/ide-file-settings.h"
#include "vcs/ide-vcs.h"
#include "threading/ide-task.h"
struct _IdeFile
{
......@@ -259,21 +260,21 @@ ide_file__file_settings_settled_cb (IdeFileSettings *file_settings,
GParamSpec *pspec,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
g_autoptr(IdeTask) task = user_data;
IdeFile *self;
IDE_ENTRY;
g_assert (IDE_IS_FILE_SETTINGS (file_settings));
g_assert (G_IS_TASK (task));
self = g_task_get_source_object (task);
g_assert (IDE_IS_TASK (task));
self = ide_task_get_source_object (task);
g_assert (IDE_IS_FILE (self));
g_signal_handlers_disconnect_by_func (file_settings,
G_CALLBACK (ide_file__file_settings_settled_cb),
task);
g_set_object (&self->file_settings, file_settings);
g_task_return_pointer (task, g_object_ref (file_settings), g_object_unref);
ide_task_return_pointer (task, g_object_ref (file_settings), g_object_unref);
IDE_EXIT;
}
......@@ -284,7 +285,7 @@ ide_file_load_settings_async (IdeFile *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_autoptr(IdeFileSettings) file_settings = NULL;
IDE_ENTRY;
......@@ -292,12 +293,12 @@ ide_file_load_settings_async (IdeFile *self,
g_return_if_fail (IDE_IS_FILE (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
task = ide_task_new (self, cancellable, callback, user_data);
/* Use shared instance if available */
if (self->file_settings != NULL)
{
g_task_return_pointer (task, g_object_ref (self->file_settings), g_object_unref);
ide_task_return_pointer (task, g_object_ref (self->file_settings), g_object_unref);
IDE_EXIT;
}
......@@ -310,7 +311,7 @@ ide_file_load_settings_async (IdeFile *self,
if (ide_file_settings_get_settled (file_settings))
{
self->file_settings = g_steal_pointer (&file_settings);
g_task_return_pointer (task, g_object_ref (self->file_settings), g_object_unref);
ide_task_return_pointer (task, g_object_ref (self->file_settings), g_object_unref);
IDE_EXIT;
}
......@@ -323,7 +324,7 @@ ide_file_load_settings_async (IdeFile *self,
"notify::settled",
G_CALLBACK (ide_file__file_settings_settled_cb),
g_object_ref (task));
g_task_set_task_data (task, g_steal_pointer (&file_settings), g_object_unref);
ide_task_set_task_data (task, g_steal_pointer (&file_settings), g_object_unref);
IDE_EXIT;
}
......@@ -345,9 +346,9 @@ ide_file_load_settings_finish (IdeFile *self,
IDE_ENTRY;
g_return_val_if_fail (G_IS_TASK (result), NULL);
g_return_val_if_fail (IDE_IS_TASK (result), NULL);
ret = g_task_propagate_pointer (G_TASK (result), error);
ret = ide_task_propagate_pointer (IDE_TASK (result), error);
IDE_RETURN (ret);
}
......@@ -588,7 +589,7 @@ has_suffix (const gchar *path,
}
static void
ide_file_find_other_worker (GTask *task,
ide_file_find_other_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -600,7 +601,7 @@ ide_file_find_other_worker (GTask *task,
g_autofree gchar *prefix = NULL;
g_autofree gchar *uri = NULL;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_FILE (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
......@@ -616,10 +617,10 @@ ide_file_find_other_worker (GTask *task,
}
else
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_INVALID_FILENAME,
"File is missing a suffix.");
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_INVALID_FILENAME,
"File is missing a suffix.");
return;
}
......@@ -637,18 +638,18 @@ ide_file_find_other_worker (GTask *task,
{
IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
g_task_return_pointer (task,
ide_file_new (context, gfile),
g_object_unref);
ide_task_return_pointer (task,
ide_file_new (context, gfile),
g_object_unref);
return;
}
}
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Failed to locate other file.");
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Failed to locate other file.");
}
void
......@@ -657,13 +658,13 @@ ide_file_find_other_async (IdeFile *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GTask) task = NULL;
g_autoptr(IdeTask) task = NULL;
g_return_if_fail (IDE_IS_FILE (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_run_in_thread (task, ide_file_find_other_worker);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_run_in_thread (task, ide_file_find_other_worker);
}
/**
......@@ -684,9 +685,9 @@ ide_file_find_other_finish (IdeFile *self,
GError **error)
{
g_return_val_if_fail (IDE_IS_FILE (self), NULL);
g_return_val_if_fail (G_IS_TASK (result), NULL);
g_return_val_if_fail (IDE_IS_TASK (result), NULL);
return g_task_propagate_pointer (G_TASK (result), error);
return ide_task_propagate_pointer (IDE_TASK (result), error);
}
static IdeFile *
......
......@@ -25,6 +25,7 @@
#include "ide-debug.h"
#include "gsettings/ide-language-defaults.h"
#include "threading/ide-task.h"
#define SCHEMA_ID "org.gnome.builder.editor.language"
#define PATH_BASE "/org/gnome/builder/editor/language/"
......@@ -242,7 +243,7 @@ ide_language_defaults_get_defaults (GError **error)
}
static void
ide_language_defaults_init_worker (GTask *task,
ide_language_defaults_init_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
......@@ -259,7 +260,7 @@ ide_language_defaults_init_worker (GTask *task,
IDE_ENTRY;
g_assert (G_IS_TASK (task));
g_assert (IDE_IS_TASK (task));
g_assert (source_object == NULL);
g_assert (task_data == NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
......@@ -273,7 +274,7 @@ ide_language_defaults_init_worker (GTask *task,
if (current_version < 0)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}
......@@ -291,17 +292,17 @@ ide_language_defaults_init_worker (GTask *task,
if (!ret)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}
if (!g_key_file_has_group (key_file, "global") ||
!g_key_file_has_key (key_file, "global", "version", NULL))
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
_("language defaults missing version in [global] group."));
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
_("language defaults missing version in [global] group."));
IDE_GOTO (failure);
}
......@@ -309,7 +310,7 @@ ide_language_defaults_init_worker (GTask *task,
if (global_version == 0 && error != NULL)
{
g_task_return_error (task, g_steal_pointer (&error));
ide_task_return_error (task, g_steal_pointer (&error));
IDE_GOTO (failure);
}