[gtksourceview/gtksourceview-5-4] completioncell: short-circuit common reset paths
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-5-4] completioncell: short-circuit common reset paths
- Date: Thu, 21 Apr 2022 20:07:31 +0000 (UTC)
commit 97ef774c7db555fb33ddd325fcb8bfd2ac56acd4
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 19 14:26:26 2022 -0700
completioncell: short-circuit common reset paths
If code paths are resetting a cell which is essentially already empty,
then we want to short-circuit and do nothing.
gtksourceview/gtksourcecompletioncell.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/gtksourcecompletioncell.c b/gtksourceview/gtksourcecompletioncell.c
index 2829454a..108f36ad 100644
--- a/gtksourceview/gtksourcecompletioncell.c
+++ b/gtksourceview/gtksourcecompletioncell.c
@@ -254,7 +254,10 @@ gtk_source_completion_cell_set_markup (GtkSourceCompletionCell *self,
{
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
- g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
+ if (markup == NULL && _gtk_source_completion_cell_is_empty (self))
+ {
+ return;
+ }
if (!GTK_IS_LABEL (self->child))
{
@@ -279,6 +282,11 @@ gtk_source_completion_cell_set_text (GtkSourceCompletionCell *self,
{
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
+ if (text == NULL && _gtk_source_completion_cell_is_empty (self))
+ {
+ return;
+ }
+
if (!GTK_IS_LABEL (self->child))
{
GtkWidget *child = gtk_label_new (NULL);
@@ -303,6 +311,11 @@ gtk_source_completion_cell_set_text_with_attributes (GtkSourceCompletionCell *se
{
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
+ if (text == NULL && _gtk_source_completion_cell_is_empty (self))
+ {
+ return;
+ }
+
gtk_source_completion_cell_set_text (self, text);
if (attrs != NULL)
@@ -332,6 +345,11 @@ gtk_source_completion_cell_set_paintable (GtkSourceCompletionCell *self,
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
g_return_if_fail (!paintable || GDK_IS_PAINTABLE (paintable));
+ if (paintable == NULL && _gtk_source_completion_cell_is_empty (self))
+ {
+ return;
+ }
+
gtk_source_completion_cell_set_widget (self, gtk_image_new_from_paintable (paintable));
}
@@ -360,7 +378,9 @@ gtk_source_completion_cell_set_widget (GtkSourceCompletionCell *self,
g_return_if_fail (!widget || gtk_widget_get_parent (widget) == NULL);
if (widget == self->child)
+ {
return;
+ }
g_clear_pointer (&self->child, gtk_widget_unparent);
@@ -440,6 +460,11 @@ gtk_source_completion_cell_set_icon_name (GtkSourceCompletionCell *self,
{
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
+ if (icon_name == NULL && _gtk_source_completion_cell_is_empty (self))
+ {
+ return;
+ }
+
if (!GTK_IS_IMAGE (self->child))
{
GtkWidget *image = gtk_image_new ();
@@ -459,6 +484,11 @@ gtk_source_completion_cell_set_gicon (GtkSourceCompletionCell *self,
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_CELL (self));
g_return_if_fail (!gicon || G_IS_ICON (gicon));
+ if (gicon == NULL && _gtk_source_completion_cell_is_empty (self))
+ {
+ return;
+ }
+
if (!GTK_IS_IMAGE (self->child))
{
GtkWidget *image = gtk_image_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]