[gnome-builder/wip/libide] libide: check pointer before setting property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: check pointer before setting property
- Date: Mon, 16 Mar 2015 07:17:48 +0000 (UTC)
commit f25df95b6fa483b7acf05339cd3963d7b7ecbb7d
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 16 00:00:08 2015 -0700
libide: check pointer before setting property
libide/ide-source-snippet-chunk.c | 20 +++++++++++++++-----
libide/ide-source-snippet.c | 21 +++++++++++++++------
2 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/libide/ide-source-snippet-chunk.c b/libide/ide-source-snippet-chunk.c
index b2ec336..f86fa23 100644
--- a/libide/ide-source-snippet-chunk.c
+++ b/libide/ide-source-snippet-chunk.c
@@ -187,15 +187,19 @@ ide_source_snippet_chunk_set_text (IdeSourceSnippetChunk *chunk,
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET_CHUNK (chunk));
- g_free (chunk->text);
- chunk->text = g_strdup (text);
- g_object_notify_by_pspec (G_OBJECT (chunk), gParamSpecs[PROP_TEXT]);
+ if (chunk->text != text)
+ {
+ g_free (chunk->text);
+ chunk->text = g_strdup (text);
+ g_object_notify_by_pspec (G_OBJECT (chunk), gParamSpecs[PROP_TEXT]);
+ }
}
gboolean
ide_source_snippet_chunk_get_text_set (IdeSourceSnippetChunk *chunk)
{
g_return_val_if_fail (IDE_IS_SOURCE_SNIPPET_CHUNK (chunk), FALSE);
+
return chunk->text_set;
}
@@ -204,8 +208,14 @@ ide_source_snippet_chunk_set_text_set (IdeSourceSnippetChunk *chunk,
gboolean text_set)
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET_CHUNK (chunk));
- chunk->text_set = !!text_set;
- g_object_notify_by_pspec (G_OBJECT (chunk), gParamSpecs[PROP_TEXT_SET]);
+
+ text_set = !!text_set;
+
+ if (chunk->text_set != text_set)
+ {
+ chunk->text_set = text_set;
+ g_object_notify_by_pspec (G_OBJECT (chunk), gParamSpecs[PROP_TEXT_SET]);
+ }
}
static void
diff --git a/libide/ide-source-snippet.c b/libide/ide-source-snippet.c
index 6a2a106..995e77d 100644
--- a/libide/ide-source-snippet.c
+++ b/libide/ide-source-snippet.c
@@ -154,8 +154,11 @@ ide_source_snippet_set_trigger (IdeSourceSnippet *self,
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET (self));
- g_free (self->trigger);
- self->trigger = g_strdup (trigger);
+ if (self->trigger != trigger)
+ {
+ g_free (self->trigger);
+ self->trigger = g_strdup (trigger);
+ }
}
const gchar *
@@ -172,8 +175,11 @@ ide_source_snippet_set_language (IdeSourceSnippet *self,
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET (self));
- g_free (self->language);
- self->language = g_strdup (language);
+ if (self->language != language)
+ {
+ g_free (self->language);
+ self->language = g_strdup (language);
+ }
}
const gchar *
@@ -190,8 +196,11 @@ ide_source_snippet_set_description (IdeSourceSnippet *self,
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET (self));
- g_free (self->description);
- self->description = g_strdup (description);
+ if (self->description != description)
+ {
+ g_free (self->description);
+ self->description = g_strdup (description);
+ }
}
static gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]