From: Kazuhiro N. <zn...@mb...> - 2004-03-13 23:00:19
|
西山和広です。 いろいろ試していたら他にも配列の場合にバグっていたようで、 gconfdが落ちたりinvalidなデータになったりしていたようです。 Index: gconf/src/rbgconf-util.c =================================================================== RCS file: /cvsroot/ruby-gnome2/ruby-gnome2/gconf/src/rbgconf-util.c,v retrieving revision 1.4 diff -u -p -r1.4 rbgconf-util.c --- gconf/src/rbgconf-util.c 4 Feb 2003 21:28:48 -0000 1.4 +++ gconf/src/rbgconf-util.c 13 Mar 2004 22:18:33 -0000 @@ -60,12 +60,13 @@ rb_ary_to_gconfval_list(ary_val, list_ty /* uh, oh. not all elements were of the same type. */ if (type != GCONF_VALUE_INVALID && type != val->type) { *list_type = GCONF_VALUE_INVALID; - return NULL; + return list; } + type = val->type; list = g_slist_append(list, val); } - + *list_type = type; return list; } @@ -102,18 +103,7 @@ rb_value_to_gconf_value(val) GSList *list; list = rb_ary_to_gconfval_list(val, &type); - if (type != GCONF_VALUE_INVALID) { - gval = gconf_value_new(GCONF_VALUE_LIST); - gconf_value_set_list_type(gval, type); - gconf_value_set_list_nocopy(gval, list); - } else if (g_slist_length(list) == 2) { - gval = gconf_value_new(GCONF_VALUE_PAIR); - gconf_value_set_car_nocopy(gval, - (GConfValue *)g_slist_nth_data(list, 0)); - gconf_value_set_car_nocopy(gval, - (GConfValue *)g_slist_nth_data(list, 1)); - g_slist_free(list); - } else { + if (type == GCONF_VALUE_INVALID) { GSList *i; for (i = list; i != NULL; i = i->next) { gconf_value_free((GConfValue *)i->data); @@ -122,6 +112,17 @@ rb_value_to_gconf_value(val) rb_raise(rb_eArgError, "all elements must be of same type"); + } else if (g_slist_length(list) == 2) { + gval = gconf_value_new(GCONF_VALUE_PAIR); + gconf_value_set_car_nocopy(gval, + (GConfValue *)g_slist_nth_data(list, 0)); + gconf_value_set_cdr_nocopy(gval, + (GConfValue *)g_slist_nth_data(list, 1)); + g_slist_free(list); + } else { + gval = gconf_value_new(GCONF_VALUE_LIST); + gconf_value_set_list_type(gval, type); + gconf_value_set_list_nocopy(gval, list); } break; } @@ -165,13 +166,8 @@ static VALUE gconfval_pair_to_rb_ary(car, cdr) GConfValue *car, *cdr; { - VALUE ary; - - ary = rb_ary_new2(2); - rb_ary_push(ary, gconf_value_to_rb_value(car)); - rb_ary_push(ary, gconf_value_to_rb_value(cdr)); - - return ary; + return rb_assoc_new(gconf_value_to_rb_value(car), + gconf_value_to_rb_value(cdr)); } /* @@ -197,7 +193,7 @@ gconf_value_to_rb_value(gval) val = CSTR2RVAL(gconf_value_get_string(gval)); break; case GCONF_VALUE_INT: - val = INT2FIX(gconf_value_get_int(gval)); + val = INT2NUM(gconf_value_get_int(gval)); break; case GCONF_VALUE_FLOAT: val = rb_float_new(gconf_value_get_float(gval)); -- |ZnZ(ゼット エヌ ゼット) |西山和広(Kazuhiro NISHIYAMA) |