我在整理一些旧的杂乱代码中的铸件时遇到问题,试图将其更新。它有这样的代码:
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
发生了什么,为什么会失败?以及如何调试它?