[libhandy] flap: Check enum values in their setters



commit 44499adcf142e3c05e45a4faa3578229f13629f4
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Jan 6 17:27:06 2021 +0100

    flap: Check enum values in their setters
    
    This warns of misuses of the API instead of either crashing or having
    unexpected results.

 src/hdy-flap.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index c22ef964..d67355e3 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -2153,6 +2153,7 @@ hdy_flap_set_flap_position (HdyFlap     *self,
                             GtkPackType  position)
 {
   g_return_if_fail (HDY_IS_FLAP (self));
+  g_return_if_fail (position <= GTK_PACK_END);
 
   if (self->flap_position == position)
     return;
@@ -2296,6 +2297,7 @@ hdy_flap_set_fold_policy (HdyFlap           *self,
                           HdyFlapFoldPolicy  policy)
 {
   g_return_if_fail (HDY_IS_FLAP (self));
+  g_return_if_fail (policy <= HDY_FLAP_FOLD_POLICY_AUTO);
 
   if (self->fold_policy == policy)
     return;
@@ -2469,6 +2471,7 @@ hdy_flap_set_transition_type (HdyFlap               *self,
                               HdyFlapTransitionType  transition_type)
 {
   g_return_if_fail (HDY_IS_FLAP (self));
+  g_return_if_fail (transition_type <= HDY_FLAP_TRANSITION_TYPE_SLIDE);
 
   if (self->transition_type == transition_type)
     return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]