Bug 339634 GLib-GObject-CRITICAL **: gtype.c:2215: initialization

assertion failed, use IA__g_type_init() prior to this function
r+sr=roc
This commit is contained in:
ginn.chen%sun.com 2006-06-06 03:40:08 +00:00
Родитель e9856fc45d
Коммит df26c4799b
1 изменённых файлов: 32 добавлений и 22 удалений

Просмотреть файл

@ -79,16 +79,28 @@ enum MaiInterfaceType {
MAI_INTERFACE_TEXT /* 7 */ MAI_INTERFACE_TEXT /* 7 */
}; };
static const GType AtkTypeForMai[] = { static GType GetAtkTypeForMai(MaiInterfaceType type)
ATK_TYPE_COMPONENT, {
ATK_TYPE_ACTION, switch (type) {
ATK_TYPE_VALUE, case MAI_INTERFACE_COMPONENT:
ATK_TYPE_EDITABLE_TEXT, return ATK_TYPE_COMPONENT;
ATK_TYPE_HYPERTEXT, case MAI_INTERFACE_ACTION:
ATK_TYPE_SELECTION, return ATK_TYPE_ACTION;
ATK_TYPE_TABLE, case MAI_INTERFACE_VALUE:
ATK_TYPE_TEXT return ATK_TYPE_VALUE;
}; case MAI_INTERFACE_EDITABLE_TEXT:
return ATK_TYPE_EDITABLE_TEXT;
case MAI_INTERFACE_HYPERTEXT:
return ATK_TYPE_HYPERTEXT;
case MAI_INTERFACE_SELECTION:
return ATK_TYPE_SELECTION;
case MAI_INTERFACE_TABLE:
return ATK_TYPE_TABLE;
case MAI_INTERFACE_TEXT:
return ATK_TYPE_TEXT;
}
return G_TYPE_INVALID;
}
static const GInterfaceInfo atk_if_infos[] = { static const GInterfaceInfo atk_if_infos[] = {
{(GInterfaceInitFunc)componentInterfaceInitCB, {(GInterfaceInitFunc)componentInterfaceInitCB,
@ -388,9 +400,9 @@ GetMaiAtkType(PRUint16 interfacesBits)
}; };
/* /*
* The members we used to register a GType are MaiInterface::GetAtkType() * The members we use to register GTypes are GetAtkTypeForMai
* and MaiInterface::GetInterfaceInfo(), which is the same with different * and atk_if_infos, which are constant values to each MaiInterface
* MaiInterface objects. So we can reuse the registered GType when having * So we can reuse the registered GType when having
* the same MaiInterface types. * the same MaiInterface types.
*/ */
const char *atkTypeName = GetUniqueMaiAtkTypeName(interfacesBits); const char *atkTypeName = GetUniqueMaiAtkTypeName(interfacesBits);
@ -404,19 +416,17 @@ GetMaiAtkType(PRUint16 interfacesBits)
* given object type to 4095. * given object type to 4095.
*/ */
static PRUint16 typeRegCount = 0; static PRUint16 typeRegCount = 0;
if (typeRegCount++ < 4095) { if (typeRegCount++ >= 4095) {
type = g_type_register_static(MAI_TYPE_ATK_OBJECT, return G_TYPE_INVALID;
atkTypeName,
&tinfo, GTypeFlags(0));
}
else {
return 0;
} }
type = g_type_register_static(MAI_TYPE_ATK_OBJECT,
atkTypeName,
&tinfo, GTypeFlags(0));
for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(AtkTypeForMai); index++) { for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(atk_if_infos); index++) {
if (interfacesBits & (1 << index)) { if (interfacesBits & (1 << index)) {
g_type_add_interface_static(type, g_type_add_interface_static(type,
AtkTypeForMai[index], GetAtkTypeForMai((MaiInterfaceType)index),
&atk_if_infos[index]); &atk_if_infos[index]);
} }
} }