gpt4 book ai didi

vala - 错误 : Return value transfers ownership but method return type hasn't been declared to transfer ownership

转载 作者:行者123 更新时间:2023-12-01 13:17:49 26 4
gpt4 key购买 nike

以下代码:

public string add_button_tooltip_markup {
get { return add_button.get_tooltip_markup (); }
set { add_button.tooltip_markup = value; }
}

给了我以下错误:
error: Return value transfers ownership but method return type hasn't been declared to transfer ownership
get { return add_button.get_tooltip_markup (); }

我正在使用 Vala 0.40.10。

在 Vala 中解决此问题的最佳方法是什么?

最佳答案

将 getter 标记为已拥有,如下所示:

public string add_button_tooltip_markup {
owned get { return add_button.get_tooltip_markup (); }
set { add_button.tooltip_markup = value; }
}

有关更多详细信息,请参阅以下页面:
https://wiki.gnome.org/Projects/Vala/ReferenceHandling

关于vala - 错误 : Return value transfers ownership but method return type hasn't been declared to transfer ownership,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53063902/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com