我在整理一些旧杂波代码中的铸件时遇到问题,试图使其更新。它有这样的代码:铸造GTK杂波纹理和正常杂波纹理
static void image_init(CtkImage *image)
{
priv->texture = clutter_texture_new();
...
}
static void refresh_icon (CtkImage *image)
{
CtkImagePrivate *priv = image->priv;
gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (priv->texture), priv->pixbuf, NULL);
}
这将产生此编译时错误:
error: passing argument 1 of ‘gtk_clutter_texture_set_from_pixbuf’ from incompatible pointer type [-Werror]
/usr/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-texture.h:99:17: note: expected ‘struct GtkClutterTexture *’ but argument is of type ‘struct ClutterTexture *’
我以为我可以用GTK_CLUTTER_TEXTURE修复它,这并不编译,但运行时错误和不足pixbufs的:
gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (texture), tiled, NULL);
结果造成:
GLib-GObject-WARNING **: invalid cast from `ClutterTexture' to `GtkClutterTexture'
Clutter-Gtk-CRITICAL **: gtk_clutter_texture_set_from_pixbuf: assertion `GTK_CLUTTER_IS_TEXTURE (texture)' failed
这是怎么回事,为什么这会失败?以及它如何被调试?
我没有在示例代码中显示它(道歉),但我们有一个gtk_clutter_texture_new,它附加到一个私人对象,所以我不想让这个例子复杂化。我已经更新了它。 – 2012-03-13 14:05:28