[gnome-builder] various: style cleanup and more assertions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] various: style cleanup and more assertions
- Date: Thu, 4 Jan 2018 10:31:41 +0000 (UTC)
commit 1898123dca6dac43f17706569542a632af450da5
Author: Christian Hergert <chergert redhat com>
Date: Thu Jan 4 02:17:33 2018 -0800
various: style cleanup and more assertions
src/libide/buffers/ide-buffer-manager.c | 9 ++---
src/libide/buffers/ide-buffer.c | 6 ++-
.../documentation/ide-documentation-proposal.c | 33 +++++---------------
src/libide/files/ide-file-settings.c | 5 ++-
src/plugins/git/ide-git-buffer-change-monitor.c | 28 +++++++++-------
.../history/gbp-history-editor-view-addin.c | 2 +
6 files changed, 37 insertions(+), 46 deletions(-)
---
diff --git a/src/libide/buffers/ide-buffer-manager.c b/src/libide/buffers/ide-buffer-manager.c
index 0cfe958..9e1dcb0 100644
--- a/src/libide/buffers/ide-buffer-manager.c
+++ b/src/libide/buffers/ide-buffer-manager.c
@@ -726,7 +726,7 @@ ide_buffer_manager__load_file_query_info_cb (GObject *object,
g_object_ref (state->progress),
g_object_unref,
ide_buffer_manager_load_file__load_cb,
- g_object_ref (task));
+ g_steal_pointer (&task));
IDE_EXIT;
}
@@ -1743,14 +1743,13 @@ unregister_auto_save (IdeBufferManager *self,
GPtrArray *
ide_buffer_manager_get_buffers (IdeBufferManager *self)
{
- GPtrArray *ret;
- gsize i;
+ g_autoptr(GPtrArray) ret = NULL;
g_return_val_if_fail (IDE_IS_BUFFER_MANAGER (self), NULL);
ret = g_ptr_array_new_with_free_func (g_object_unref);
- for (i = 0; i < self->buffers->len; i++)
+ for (guint i = 0; i < self->buffers->len; i++)
{
IdeBuffer *buffer;
@@ -1758,7 +1757,7 @@ ide_buffer_manager_get_buffers (IdeBufferManager *self)
g_ptr_array_add (ret, g_object_ref (buffer));
}
- return ret;
+ return g_steal_pointer (&ret);
}
/**
diff --git a/src/libide/buffers/ide-buffer.c b/src/libide/buffers/ide-buffer.c
index b1afec5..30ac62e 100644
--- a/src/libide/buffers/ide-buffer.c
+++ b/src/libide/buffers/ide-buffer.c
@@ -598,16 +598,17 @@ ide_buffer__file_load_settings_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- g_autoptr(IdeBuffer) self = user_data;
IdeFile *file = (IdeFile *)object;
+ g_autoptr(IdeBuffer) self = user_data;
g_autoptr(IdeFileSettings) file_settings = NULL;
g_assert (IDE_IS_BUFFER (self));
+ g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_FILE (file));
file_settings = ide_file_load_settings_finish (file, result, NULL);
- if (file_settings)
+ if (file_settings != NULL)
{
gboolean insert_trailing_newline;
@@ -2476,6 +2477,7 @@ ide_buffer__check_for_volume_cb (GObject *object,
GFile *file = (GFile *)object;
g_assert (IDE_IS_BUFFER (self));
+ g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_FILE (file));
file_info = g_file_query_info_finish (file, result, NULL);
diff --git a/src/libide/documentation/ide-documentation-proposal.c
b/src/libide/documentation/ide-documentation-proposal.c
index 85828b5..daef0a2 100644
--- a/src/libide/documentation/ide-documentation-proposal.c
+++ b/src/libide/documentation/ide-documentation-proposal.c
@@ -22,9 +22,9 @@
typedef struct
{
- gchar *header;
- gchar *text;
- gchar *uri;
+ gchar *header;
+ gchar *text;
+ gchar *uri;
} IdeDocumentationProposalPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (IdeDocumentationProposal, ide_documentation_proposal, G_TYPE_OBJECT)
@@ -77,7 +77,6 @@ ide_documentation_proposal_get_uri (IdeDocumentationProposal *self)
return priv->uri;
}
-
void
ide_documentation_proposal_set_header (IdeDocumentationProposal *self,
const gchar *header)
@@ -110,22 +109,11 @@ ide_documentation_proposal_set_text (IdeDocumentationProposal *self,
}
}
-void
-ide_documentation_proposal_set_uri (IdeDocumentationProposal *self,
- const gchar *uri)
-{
- IdeDocumentationProposalPrivate *priv = ide_documentation_proposal_get_instance_private (self);
-
- g_return_if_fail (IDE_IS_DOCUMENTATION_PROPOSAL (self));
-
- priv->uri = g_strdup (uri);
-}
-
static void
ide_documentation_proposal_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
IdeDocumentationProposal *self = IDE_DOCUMENTATION_PROPOSAL (object);
@@ -155,6 +143,7 @@ ide_documentation_proposal_set_property (GObject *object,
GParamSpec *pspec)
{
IdeDocumentationProposal *self = IDE_DOCUMENTATION_PROPOSAL (object);
+ IdeDocumentationProposalPrivate *priv = ide_documentation_proposal_get_instance_private (self);
switch (prop_id)
{
@@ -167,7 +156,7 @@ ide_documentation_proposal_set_property (GObject *object,
break;
case PROP_URI:
- ide_documentation_proposal_set_uri (self, g_value_get_string (value));
+ priv->uri = g_value_dup_string (value);
break;
default:
@@ -224,10 +213,4 @@ ide_documentation_proposal_class_init (IdeDocumentationProposalClass *klass)
void
ide_documentation_proposal_init (IdeDocumentationProposal *self)
{
- IdeDocumentationProposalPrivate *priv = ide_documentation_proposal_get_instance_private (self);
-
- priv->header = NULL;
- priv->text = NULL;
- priv->uri = NULL;
}
-
diff --git a/src/libide/files/ide-file-settings.c b/src/libide/files/ide-file-settings.c
index 6171f10..20b5a39 100644
--- a/src/libide/files/ide-file-settings.c
+++ b/src/libide/files/ide-file-settings.c
@@ -354,8 +354,9 @@ _ide_file_settings_append (IdeFileSettings *self,
{
IdeFileSettingsPrivate *priv = ide_file_settings_get_instance_private (self);
- g_return_if_fail (IDE_IS_FILE_SETTINGS (self));
- g_return_if_fail (IDE_IS_FILE_SETTINGS (child));
+ g_assert (IDE_IS_FILE_SETTINGS (self));
+ g_assert (IDE_IS_FILE_SETTINGS (child));
+ g_assert (self != child);
g_signal_connect_object (child,
"notify",
diff --git a/src/plugins/git/ide-git-buffer-change-monitor.c b/src/plugins/git/ide-git-buffer-change-monitor.c
index a21b8ef..ec63fa7 100644
--- a/src/plugins/git/ide-git-buffer-change-monitor.c
+++ b/src/plugins/git/ide-git-buffer-change-monitor.c
@@ -149,11 +149,16 @@ ide_git_buffer_change_monitor_calculate_async (IdeGitBufferChangeMonitor *self,
self->state_dirty = FALSE;
task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, ide_git_buffer_change_monitor_calculate_async);
+ g_task_set_priority (task, G_PRIORITY_LOW);
file = ide_buffer_get_file (self->buffer);
+ g_assert (IDE_IS_FILE (file));
+
gfile = ide_file_get_file (file);
+ g_assert (!gfile || G_IS_FILE (gfile));
- if (!gfile)
+ if (gfile == NULL)
{
g_task_return_new_error (task,
G_IO_ERROR,
@@ -173,7 +178,7 @@ ide_git_buffer_change_monitor_calculate_async (IdeGitBufferChangeMonitor *self,
self->in_calculation = TRUE;
- g_async_queue_push (work_queue, g_object_ref (task));
+ g_async_queue_push (work_queue, g_steal_pointer (&task));
}
static IdeBufferLineChange
@@ -656,7 +661,7 @@ static gpointer
ide_git_buffer_change_monitor_worker (gpointer data)
{
GAsyncQueue *queue = data;
- GTask *task;
+ gpointer taskptr;
g_assert (queue != NULL);
@@ -668,22 +673,25 @@ ide_git_buffer_change_monitor_worker (gpointer data)
* share the same GgitRepository amongst themselves).
*/
- while ((task = g_async_queue_pop (queue)))
+ while (NULL != (taskptr = g_async_queue_pop (queue)))
{
IdeGitBufferChangeMonitor *self;
g_autoptr(GError) error = NULL;
+ g_autoptr(GTask) task = taskptr;
DiffTask *diff;
self = g_task_get_source_object (task);
+ g_assert (IDE_IS_GIT_BUFFER_CHANGE_MONITOR (self));
+
diff = g_task_get_task_data (task);
+ g_assert (diff != NULL);
if (!ide_git_buffer_change_monitor_calculate_threaded (self, diff, &error))
g_task_return_error (task, g_steal_pointer (&error));
else
- g_task_return_pointer (task, g_hash_table_ref (diff->state),
+ g_task_return_pointer (task,
+ g_hash_table_ref (diff->state),
(GDestroyNotify)g_hash_table_unref);
-
- g_object_unref (task);
}
return NULL;
@@ -694,11 +702,7 @@ ide_git_buffer_change_monitor_dispose (GObject *object)
{
IdeGitBufferChangeMonitor *self = (IdeGitBufferChangeMonitor *)object;
- if (self->changed_timeout)
- {
- g_source_remove (self->changed_timeout);
- self->changed_timeout = 0;
- }
+ dzl_clear_source (&self->changed_timeout);
dzl_clear_weak_pointer (&self->buffer);
diff --git a/src/plugins/history/gbp-history-editor-view-addin.c
b/src/plugins/history/gbp-history-editor-view-addin.c
index 18aa02b..19561ad 100644
--- a/src/plugins/history/gbp-history-editor-view-addin.c
+++ b/src/plugins/history/gbp-history-editor-view-addin.c
@@ -152,6 +152,8 @@ static void
gbp_history_editor_view_addin_queue (GbpHistoryEditorViewAddin *self,
guint line)
{
+ g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+
/*
* If the buffer is modified, we want to keep track of this position in the
* history (the layout stack will automatically merge it with the previous
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]