Re: GtkSelectionData:: get_uris/set_uris override
| From: | Christian Weiske | Date: | Thu, 27 Jul 2006 19:53:19 +0000 |
| Subject: | Re: GtkSelectionData:: get_uris/set_uris override | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-3336@lists.php.net to get a copy of this message | ||
Bump.
Christian Weiske wrote:
> Hi all,
>
>
> I made a patch for GtkSelectionData::get_uris() and set_uris().
> My demo script works, I am just unsure about how to free the gchar list
> in get_uris().
> Andrei, could you check it?
>
>
> And together with this patch, I'm able to reproduce the
>> *** glibc detected *** corrupted double-linked list: 0x08dd5e00 ***
> error I had already yesterday with drag and drop - just drop 3x on
> itself. (This has nothing to do with this patch, as it already came
> yesterday now and then). The demo script will be attached to the bug I'm
> about to open now.
>
>
>
> ------------------------------------------------------------------------
>
> %% {{{ GtkSelectionData
>
> %%
> override gtk_selection_data_get_uris
> PHP_METHOD
> {
> gchar **ret;
> gchar *cp_str;
> gsize cp_len;
> zend_bool free_cp_str;
> GtkSelectionData *selection_data = NULL;
>
> if (!php_gtk_parse_args(ZEND_NUM_ARGS(), ""))
> return;
>
> selection_data = (GtkSelectionData *) PHPG_GBOXED(this_ptr);
> ret = gtk_selection_data_get_uris(selection_data);
> if (ret) {
> array_init(return_value);
> while (*ret) {
> cp_str = phpg_from_utf8(*ret, strlen(*ret), &cp_len, &free_cp_str
> TSRMLS_CC);
> if (cp_str) {
> add_next_index_stringl(return_value, cp_str, cp_len, !free_cp_str);
> } else {
> zval_dtor(return_value);
> RETURN_NULL();
> }
> *ret++;
> }
> // g_strfreev(*ret);
> } else {
> RETURN_NULL();
> }
> }
>
> %%
> add-arginfo GtkSelectionData set_uris
> static
> ZEND_BEGIN_ARG_INFO(ARGINFO_NAME, 0)
> ZEND_ARG_INFO(0, uris)
> ZEND_END_ARG_INFO();
>
> %%
> override gtk_selection_data_set_uris
> PHP_METHOD
> {
> gchar **uris;
> zval *arr = NULL;
> zval **data;
> int i, arr_count;
> GtkSelectionData *selection_data = NULL;
>
> if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "a", &arr)) {
> return;
> }
>
> arr_count = zend_hash_num_elements(Z_ARRVAL_P(arr));
> uris = safe_emalloc(arr_count+1, sizeof (gchar *), 0);
>
> for (i=0, zend_hash_internal_pointer_reset(Z_ARRVAL_P(arr));
> zend_hash_get_current_data(Z_ARRVAL_P(arr), (void **)&data) == SUCCESS;
> zend_hash_move_forward(Z_ARRVAL_P(arr))) {
>
> convert_to_string_ex(data);
> uris[i++] = Z_STRVAL_PP(data);
>
> }
>
> uris[i] = NULL;
> selection_data = (GtkSelectionData *) PHPG_GBOXED(this_ptr);
> gtk_selection_data_set_uris(selection_data, (
--
Regards/MfG,
Christian Weiske
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc