Branch: Tag:

2016-01-22

2016-01-22 19:25:46 by Chris Angelico <rosuav@gmail.com>

GTK2: Break out G_TYPE_ENUM handling to a special case.

Actual enumerations are subtypes of enum, so the equality check in
the generic handler doesn't catch them. Prevents assertion failures
in signal handlers.

529:    case G_TYPE_INT:    retval=(LONGEST)g_value_get_int(a);    break; -  case G_TYPE_ENUM: -  retval=(LONGEST)g_value_get_enum(a); -  break; +     case G_TYPE_FLAGS:    retval=(LONGEST)g_value_get_flags(a);    break;
556:    return PUSHED_VALUE;   }    + static int pgtk2_push_enum_param(const GValue *a) { +  /* This can't be handled by push_int_param as the type of +  an enumeration is some subclass of G_TYPE_ENUM, rather than +  actually being G_TYPE_ENUM exactly. */ +  push_int64((LONGEST)g_value_get_enum(a)); +  return PUSHED_VALUE; + } +    static int pgtk2_push_float_param(const GValue *a) {    FLOAT_TYPE retval;    if (G_VALUE_TYPE(a)==G_TYPE_FLOAT)
659:    CB( G_TYPE_INT, pgtk2_push_int_param );    CB( G_TYPE_INT64, pgtk2_push_int_param );    CB( G_TYPE_UINT64, pgtk2_push_int_param ); -  CB( G_TYPE_ENUM, pgtk2_push_int_param ); +  CB( G_TYPE_ENUM, pgtk2_push_enum_param );    CB( G_TYPE_FLAGS, pgtk2_push_int_param );    CB( G_TYPE_BOOLEAN, pgtk2_push_int_param );    CB( G_TYPE_UINT, pgtk2_push_int_param );