[gtk/matthiasc/for-master: 2/6] checkbutton: Add a warning about cyclic groups
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/6] checkbutton: Add a warning about cyclic groups
- Date: Wed, 17 Mar 2021 11:58:25 +0000 (UTC)
commit ee837dfc1230f0a5cc398c3e2bfb32aac369dadd
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Mar 17 07:37:33 2021 -0400
checkbutton: Add a warning about cyclic groups
Setting up check or toggle button group relationships
in a cycle will lead to lockups. Add a warning about
this, and catch the simplest case with a precondition
check.
Fixes: #3763
gtk/gtkcheckbutton.c | 3 +++
gtk/gtktogglebutton.c | 3 +++
2 files changed, 6 insertions(+)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 366fd2398c..e9a30a1ce3 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -913,6 +913,8 @@ gtk_check_button_set_label (GtkCheckButton *self,
* Setting the group of a check button also changes the css name of the
* indicator widget's CSS node to 'radio'.
*
+ * Setting up groups in a cycle leads to undefined behavior.
+ *
* Note that the same effect can be achieved via the [interface@Gtk.Actionable]
* API, by using the same action with parameter type and state type 's'
* for all buttons in the group, and giving each button its own target
@@ -926,6 +928,7 @@ gtk_check_button_set_group (GtkCheckButton *self,
GtkCheckButtonPrivate *group_priv = gtk_check_button_get_instance_private (group);
g_return_if_fail (GTK_IS_CHECK_BUTTON (self));
+ g_return_if_fail (self != group);
if (!group)
{
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 6ae96fc8af..1e53a896c6 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -473,6 +473,8 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button)
* In a group of multiple toggle buttons, only one button can be active
* at a time.
*
+ * Setting up groups in a cycle leads to undefined behavior.
+ *
* Note that the same effect can be achieved via the [interface@Gtk.Actionable]
* API, by using the same action with parameter type and state type 's'
* for all buttons in the group, and giving each button its own target
@@ -486,6 +488,7 @@ gtk_toggle_button_set_group (GtkToggleButton *toggle_button,
GtkToggleButtonPrivate *group_priv = gtk_toggle_button_get_instance_private (group);
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+ g_return_if_fail (toggle_button != group);
if (!group)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]