转载时请注明出处和作者联系方式
作者联系方式:李先静 <xianjimli at hotmail dot com>
前段时间对 syncmanager进行重构,为了减少不必要的开销,我决定在需要时才加SyncSource插件,不需要时就卸载它们。在测试时发现第一次运行时正 常,第二次运行时创建DbPersistance对象时失败了。仔细看了下调试信息,里面告诉我说注册DbPersistance类型失败,因为已经 DbPersistance类型注册了。不太可能啊,对象注册类型时一般都会防止重复注册的,比如:
gtk_button_get_type (void)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
static GType button_type = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (!button_type)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
static const GTypeInfo button_info =
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sizeof (GtkButtonClass),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
NULL, /**//* base_init */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
NULL, /**//* base_finalize */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
(GClassInitFunc) gtk_button_class_init,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
NULL, /**//* class_finalize */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
NULL, /**//* class_data */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sizeof (GtkButton),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
16, /**//* n_preallocs */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
(GInstanceInitFunc) gtk_button_init,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
button_type = g_type_register_static (GTK_TYPE_BIN, "GtkButton",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
&button_info, 0);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return button_type;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)