Details

[Home]

Issue of the Implementation # D0078

Brief

The G_TYPE_CHECK_CLASS_TYPE() macro does not emit a warning if a class structure is not of the expected type

Detailed Description

According to the specification of the macro G_TYPE_CHECK_CLASS_TYPE() "Returns TRUE if g_class is a class structure of the type identified by g_type. Otherwise emits a warning and returns FALSE." Whenever class structure type does not match the type id, passed in for a second parameter, the warning is not get emitted.

Problem location(s) in the standard

Linux Standard Base Desktop Specification 3.1, Chapter 12. Libraries, 12.5.1 glib-2.0/glib-object.h; http://www.gtk.org/api/2.6/gobject/gobject-Type-Information.html#G-TYPE-CHECK-CLASS-TYPE-CAPS

Example

#include <stdio.h>
#include <glib-object.h>

gint warning_handler_call_count;
gchar *warning_handler_message;

void warning_handler (const gchar *log_domain, 
                      GLogLevelFlags log_level, 
                      const gchar *message, 
                      gpointer user_data)
{
    warning_handler_call_count++;
    warning_handler_message = g_strdup(message);
}

int main(int argc, char** argv)
{

    warning_handler_call_count = 0;
    warning_handler_message = NULL;

    g_type_init();

    gpointer g_class = g_type_class_ref(G_TYPE_OBJECT);

    g_log_set_default_handler (warning_handler, NULL);

    gboolean ret_value = 
        G_TYPE_CHECK_CLASS_TYPE(g_class, G_TYPE_INT);


    printf("ret_value=%d; message='%s'; call_count=%d\n",
        ret_value, warning_handler_message, 
        warning_handler_call_count);

    g_type_class_unref(g_class);
    if(warning_handler_message != NULL)
        g_free(warning_handler_message);


    return 0;
}

Component

gtk-gobject 2.6.2 or later

Accepted

Gnome Bugzilla 526103

[Home]