Details

[Home]

Issue of the Implementation # S0567

Brief

atk_object_connect_property_change_handler: guint instead of gulong

Detailed Description

atk_object_connect_property_change_handler returns an ID as guint. The implementation of this function uses g_signal_connect_closure_by_id which returns the ID as gulong though.

So if the latter ID is greater than the maximum guint value, the ID returned by atk_object_connect_property_change_handler cannot be processed properly by atk_object_remove_property_change_handler.
(atk_object_remove_property_change_handler calls g_signal_closure_disconnect to remove a handler with a given gulong ID).

If sizeof(int) < sizeof(long) the example code will show that the standard is violated for atk_object_connect_property_change_handler and atk_object_remove_property_change_handler.

There is the same problem with atk_component_add_focus_handler and atk_component_remove_focus_handler.

Problem location(s) in the standard

ATK 1.9.0 Reference Manual, AtkObject.

Example

#include <stdio.h>
#include <atk/atk.h>	
#include <limits.h>

gboolean handler_was_called;

void 
handler(AtkObject* object, AtkPropertyValues* prop_values)
{
    handler_was_called = TRUE;
}
void 
handler_test(AtkObject* object, AtkPropertyValues* prop_values){}

int 
main()
{
    g_type_init();

    AtkObject* obj = g_object_new(ATK_TYPE_OBJECT, NULL);
    guint handler_id = atk_object_connect_property_change_handler(
        obj,(AtkPropertyChangeHandler*)handler_test);
    gulong number_of_cycles = (sizeof(guint) != sizeof(gulong)) ?
        (G_MAXUINT - 1): 10000000;

    //Cycle of connecting and removing handlers, for increasing id.
    printf("Number of iterations is %ld ...\n", number_of_cycles);

    gulong i;
    for(i = number_of_cycles; i > 0 ;i --)
    {
        guint handler_id_tmp = 
            atk_object_connect_property_change_handler(
            obj, (AtkPropertyChangeHandler*)handler_test);
        
        atk_object_remove_property_change_handler(
            obj, 
            handler_id);
        
        handler_id = handler_id_tmp;
    }
    printf("...Cycle finished.\n");
    atk_object_remove_property_change_handler(obj, handler_id);
    //
    handler_id = atk_object_connect_property_change_handler(
                     obj,(AtkPropertyChangeHandler*)handler);

    printf("Now id of connected handler is %d.\n", 
        handler_id);

    printf("And after call of \
               atk_object_remove_property_change_handler(%d)\n", 
               handler_id);

    atk_object_remove_property_change_handler(
        obj, 
        handler_id);

    handler_was_called = FALSE;

    g_object_set(obj, "accessible-name", "some name", NULL);

    if(handler_was_called)
    {
    	printf("the handler is still called ");
    }
    else
    {
    	printf("the handler is not called any more ");
    }

    printf("when the property changes value.\n");

    return 0;
}

Component

gtk-atk 1.9.0 or later

Environment

Architectures

x86_64, ia64, ppc64, s390X

Accepted

Gnome Bugzilla 477705

[Home]