我在整理一些舊雜波代碼中的鑄件時遇到問題,試圖使其更新。它有這樣的代碼:鑄造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